



'''simple docstring'''

from __future__ import annotations

from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any



class 		lowerCamelCase__   :




					'''simple docstring'''



					A_         =    ("""_front""", """_back""", """_len""")



					@dataclass
					class 		lowerCamelCase__   :




										'''simple docstring'''



										A_         =    None
										A_         =    None
										A_         =    None






					class 		lowerCamelCase__   :




										'''simple docstring'''



										A_         =    ("""_cur""",)




										def __init__(	self					:						List[Any]  ,	UpperCamelCase_					:						Deque._Node | None       )	->							None:



											'''simple docstring'''





											_lowercase       :							Any  	=		cur




										def __iter__(	self					:						List[Any]       )	->							Deque._Iterator:



											'''simple docstring'''





											return self




										def     __UpperCAmelCase  (	self					:						Dict       )	->							Any:



											'''simple docstring'''





											if self._cur is None:
												# finished iterating
												raise StopIteration
											_lowercase       :							Tuple  	=		self._cur.val
											_lowercase       :							str  	=		self._cur.next_node

											return val






					def __init__(	self					:						int  ,	UpperCamelCase_					:						Iterable[Any] | None = None       )	->							None:



						'''simple docstring'''





						_lowercase       :							Any  	=		None
						_lowercase       :							Any  	=		None
						_lowercase       :							int  	=		0

						if iterable is not None:
							# append every value to the deque
							for val in iterable:
								self.append(UpperCamelCase_       )




					def     __UpperCAmelCase  (	self					:						Optional[Any]  ,	UpperCamelCase_					:						Any       )	->							None:



						'''simple docstring'''





						_lowercase       :							str  	=		self._Node(UpperCamelCase_  ,	UpperCamelCase_  ,	UpperCamelCase_       )
						if self.is_empty():
							# front = back
							_lowercase       :							Dict  	=		node
							_lowercase       :							Tuple  	=		1
						else:
							# connect nodes
							_lowercase       :							int  	=		node
							_lowercase       :							Optional[int]  	=		self._back
							_lowercase       :							Union[str, Any]  	=		node  # assign new back to the new node

							self._len += 1

							# make sure there were no errors
							assert not self.is_empty(), "Error on appending value."




					def     __UpperCAmelCase  (	self					:						int  ,	UpperCamelCase_					:						Any       )	->							None:



						'''simple docstring'''





						_lowercase       :							Tuple  	=		self._Node(UpperCamelCase_  ,	UpperCamelCase_  ,	UpperCamelCase_       )
						if self.is_empty():
							# front = back
							_lowercase       :							Tuple  	=		node
							_lowercase       :							List[str]  	=		1
						else:
							# connect nodes
							_lowercase       :							str  	=		self._front
							_lowercase       :							Dict  	=		node
							_lowercase       :							str  	=		node  # assign new front to the new node

							self._len += 1

							# make sure there were no errors
							assert not self.is_empty(), "Error on appending value."




					def     __UpperCAmelCase  (	self					:						List[str]  ,	UpperCamelCase_					:						Iterable[Any]       )	->							None:



						'''simple docstring'''





						for val in iterable:
							self.append(UpperCamelCase_       )




					def     __UpperCAmelCase  (	self					:						List[Any]  ,	UpperCamelCase_					:						Iterable[Any]       )	->							None:



						'''simple docstring'''





						for val in iterable:
							self.appendleft(UpperCamelCase_       )




					def     __UpperCAmelCase  (	self					:						int       )	->							Any:



						'''simple docstring'''





						assert not self.is_empty(), "Deque is empty."

						_lowercase       :							List[str]  	=		self._back
						_lowercase       :							List[Any]  	=		self._back.prev_node  # set new back
						# drop the last node - python will deallocate memory automatically
						_lowercase       :							int  	=		None

						self._len -= 1

						return topop.val




					def     __UpperCAmelCase  (	self					:						Any       )	->							Any:



						'''simple docstring'''





						assert not self.is_empty(), "Deque is empty."

						_lowercase       :							List[Any]  	=		self._front
						_lowercase       :							Optional[int]  	=		self._front.next_node  # set new front and drop the first node
						_lowercase       :							Tuple  	=		None

						self._len -= 1

						return topop.val




					def     __UpperCAmelCase  (	self					:						Dict       )	->							bool:



						'''simple docstring'''





						return self._front is None




					def __len__(	self					:						Optional[int]       )	->							int:



						'''simple docstring'''





						return self._len




					def __eq__(	self					:						Tuple  ,	UpperCamelCase_					:						object       )	->							bool:



						'''simple docstring'''





						if not isinstance(UpperCamelCase_  ,	UpperCamelCase_       ):
							return NotImplemented

						_lowercase       :							List[str]  	=		self._front
						_lowercase       :							List[str]  	=		other._front

						# if the length of the dequeues are not the same, they are not equal
						if len(self       ) != len(UpperCamelCase_       ):
							return False

						while me is not None and oth is not None:
							# compare every value
							if me.val != oth.val:
								return False
							_lowercase       :							Optional[Any]  	=		me.next_node
							_lowercase       :							List[str]  	=		oth.next_node

						return True




					def __iter__(	self					:						Dict       )	->							Deque._Iterator:



						'''simple docstring'''





						return Deque._Iterator(self._front       )




					def __repr__(	self					:						Union[str, Any]       )	->							str:



						'''simple docstring'''





						_lowercase       :							str  	=		[]
						_lowercase       :							Any  	=		self._front
						while aux is not None:
							# append the values in a list to display
							values_list.append(aux.val       )
							_lowercase       :							Union[str, Any]  	=		aux.next_node

						return F'''[{", ".join(repr(UpperCamelCase_       ) for val in values_list       )}]'''


if __name__ == "__main__":
		import doctest

		doctest.testmod()





'''simple docstring'''

def     __UpperCamelCase					(				_lowercase = 1000       )			->      int:
	_lowercase       :							Optional[int]  	=		[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       :							Any  	=		0

	for i in range(1,					n + 1       ):
		if i < 1000:
			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 // 1000] + 8
	return count


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