'''simple docstring'''




def      UpperCamelCase_							( _UpperCAmelCase  :				int = 1_000   )   ->   int:


       """simple docstring"""







       _UpperCAmelCase					:  List[str]											=   [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)
       _UpperCAmelCase					:  Optional[int]											=   [0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

       _UpperCAmelCase					:  Union[str, 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())))


'''simple docstring'''




def      UpperCamelCase_							( _UpperCAmelCase  :				int   )   ->   bool:


       """simple docstring"""







       _UpperCAmelCase					:  Optional[int]											=   9

       while num > 0:
              if num % 10 != digit:
                     return False
              num //= 100
              digit -= 1

       return True

def      UpperCamelCase_							( )   ->   int:


       """simple docstring"""







       _UpperCAmelCase					:  Optional[Any]											=   138_902_663

       while not is_square_form(num * num   ):
              if num % 10 == 3:
                     num -= 6  # (3 - 6) % 10 = 7
              else:
                     num -= 4  # (7 - 4) % 10 = 3

       return num * 10


if __name__ == "__main__":
  print(F'{solution() = }')

