


'''simple docstring'''







import hashlib
from typing import Union







def _UpperCamelCase			(	__A       )				->						Optional[Any]:


      '''simple docstring'''



      if isinstance(SCREAMING_SNAKE_CASE_ ,     SCREAMING_SNAKE_CASE_       ):
            # Data already in bytes, returns as it as
            return hash_data
      elif isinstance(SCREAMING_SNAKE_CASE_ ,     SCREAMING_SNAKE_CASE_       ):
            # We keep the data as it as for it ot be later encoded to UTF-8
            # However replace `\\` with `/` for Windows compatibility
            UpperCamelCase__      =							hash_data.replace("\\" ,     "/"       )
      elif isinstance(SCREAMING_SNAKE_CASE_ ,     SCREAMING_SNAKE_CASE_       ):
            UpperCamelCase__      =							str(SCREAMING_SNAKE_CASE_       )
      else:
            # If data is not of the required type, raise error
            raise InvalidKeyError(SCREAMING_SNAKE_CASE_       )

      return hash_data.encode("utf-8"       )
class    lowercase_	(       _snake_case  ):


    def __init__(	self    ,   a       ):
          UpperCamelCase__      =							'\nFAILURE TO GENERATE DATASET: Invalid key type detected'
          UpperCamelCase__      =							f'''\nFound Key {hash_data} of type {type(_a       )}'''
          UpperCamelCase__      =							'\nKeys should be either str, int or bytes type'
          super().__init__(f'''{self.prefix}{self.err_msg}{self.suffix}'''       )

class    lowercase_	(       _snake_case  ):


    def __init__(	self    ,   a    ,   a    ,   a=""       ):
          UpperCamelCase__      =							key
          UpperCamelCase__      =							duplicate_key_indices
          UpperCamelCase__      =							fix_msg
          UpperCamelCase__      =							'Found multiple examples generated with the same key'
          if len(_a       ) <= 20:
                UpperCamelCase__      =							f'''\nThe examples at index {', '.join(_a       )} have the key {key}'''
          else:
                UpperCamelCase__      =							f'''\nThe examples at index {', '.join(duplicate_key_indices[:20]       )}... ({len(_a       ) - 20} more) have the key {key}'''
          UpperCamelCase__      =							'\n' + fix_msg if fix_msg else ''
          super().__init__(f'''{self.prefix}{self.err_msg}{self.suffix}'''       )

class    lowercase_	:


    def __init__(	self    ,   a       ):
          UpperCamelCase__      =							hashlib.mda(_as_bytes(_a       )       )


    def   __a				(	self    ,   a       ):
          UpperCamelCase__      =							self._split_mda.copy()
          UpperCamelCase__      =							_as_bytes(_a       )
          mda.update(_a       )
          # Convert to integer with hexadecimal conversion
          return int(mda.hexdigest()    ,   16       )






'''simple docstring'''




def _UpperCamelCase (							SCREAMING_SNAKE_CASE_ = 1_000				):
     lowercase_       :							Tuple  					=       [0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8]
     # number of letters in twenty, thirty, ..., ninety (0 for numbers less than
     # 20 due to inconsistency in teens)
     lowercase_       :							List[Any]  					=       [0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

     lowercase_       :							Optional[Any]  					=       0

     for i in range(1	,							n + 1				):
          if i < 1_000:
               if i >= 100:
                    # add number of letters for "n hundred"
                    count += ones_counts[i // 100] + 7

                    if i % 100 != 0:
                         # add number of letters for "and" if number is not multiple
                         # of 100
                         count += 3

               if 0 < i % 100 < 20:
                    # add number of letters for one, two, three, ..., nineteen
                    # (could be combined with below if not for inconsistency in
                    # teens)
                    count += ones_counts[i % 100]
               else:
                    # add number of letters for twenty, twenty one, ..., ninety
                    # nine
                    count += ones_counts[i % 10]
                    count += tens_counts[(i % 100 - i % 10) // 10]
          else:
               count += ones_counts[i // 1_000] + 8
     return count


if __name__ == "__main__":
 print(solution(int(input().strip())))




