

from functools import partial
from typing import Any, Callable, Dict, List, Type, TypeVar, Union, overload

import torch
import torch.nn as nn
import torch.types





def 	snake_case_      (__A     :						torch.Tensor					,   __A     :						torch.Tensor					,   __A     :						bool     )			->	torch.Tensor:
   # The first operation in a checkpoint can't be in-place, but it's
   # nice to have in-place addition during inference. Thus...
   if not inplace:
      __lowerCAmelCase  :			Dict					    =						ma + ma
   else:
      ma += ma

   return ma





def 	snake_case_      (__A     :						torch.Tensor					,   __A     :						List[int]     )			->	torch.Tensor:
   __lowerCAmelCase  :			List[str]					    =						-1 * len(__A     )
   __lowerCAmelCase  :			List[Any]					    =						list(range(len(tensor.shape[:zero_index]     )     )     )
   return tensor.permute(first_inds + [zero_index + i for i in inds]     )





def 	snake_case_      (__A     :						torch.Tensor					,   __A     :						int     )			->	torch.Tensor:
   return t.reshape(t.shape[:-no_dims] + (-1,)     )





def 	snake_case_      (__A     :						torch.Tensor					,   __A     :						torch.Tensor					,   __A     :						int					,   __A     :						float = 1e-4     )			->	torch.Tensor:
   __lowerCAmelCase  :			Any					    =						mask.expand(*value.shape     )
   return torch.sum(mask * value					,   dim=__A     ) / (eps + torch.sum(__A					,   dim=__A     ))





def 	snake_case_      (__A     :						torch.Tensor					,   __A     :						torch.types.Number = 2.3125					,   __A     :						torch.types.Number = 21.6875					,   __A     :						int = 6_4     )			->	torch.Tensor:
   __lowerCAmelCase  :			Tuple					    =						torch.linspace(__A					,   __A					,   no_bins - 1					,   device=pts.device     )
   __lowerCAmelCase  :			Tuple					    =						torch.sqrt(torch.sum((pts.unsqueeze(-2     ) - pts.unsqueeze(-3     )) ** 2					,   dim=-1     )     )
   return torch.bucketize(__A					,   __A     )





def 	snake_case_      (__A     :						Callable[[list], Any]					,   __A     :						List[dict]     )			->	dict:
   __lowerCAmelCase  :			List[str]					    =						dicts[0]
   __lowerCAmelCase  :			str					    =						{}
   for k, v in first.items():
      __lowerCAmelCase  :			Any					    =						[d[k] for d in dicts]
      if isinstance(__A					,   __A     ):
         __lowerCAmelCase  :			List[str]					    =						dict_multimap(__A					,   __A     )
      else:
         __lowerCAmelCase  :			Tuple					    =						fn(__A     )

   return new_dict





def 	snake_case_      (__A     :						torch.Tensor					,   __A     :						torch.Tensor     )			->	torch.Tensor:
   __lowerCAmelCase  :			Any					    =						v_bins.view(((1,) * len(x.shape     )) + (len(__A     ),)     )
   __lowerCAmelCase  :			Dict					    =						x[..., None] - reshaped_bins
   __lowerCAmelCase  :			Dict					    =						torch.argmin(torch.abs(__A     )					,   dim=-1     )
   return nn.functional.one_hot(__A					,   num_classes=len(__A     )     ).float()





def 	snake_case_      (__A     :						torch.Tensor					,   __A     :						torch.Tensor					,   __A     :						int = 0					,   __A     :						int = 0     )			->	torch.Tensor:
   __lowerCAmelCase  :			List[Union[slice, torch.Tensor]]					    =						[]
   for i, s in enumerate(data.shape[:no_batch_dims]     ):
      __lowerCAmelCase  :			Optional[int]					    =						torch.arange(__A     )
      __lowerCAmelCase  :			Dict					    =						r.view(*(*((1,) * i), -1, *((1,) * (len(inds.shape     ) - i - 1)))     )
      ranges.append(__A     )

   __lowerCAmelCase  :			List[Union[slice, torch.Tensor]]					    =						[slice(__A     ) for _ in range(len(data.shape     ) - no_batch_dims     )]
   __lowerCAmelCase  :			List[Any]					    =						inds
   ranges.extend(__A     )
   # Matt note: Editing this to get around the behaviour of using a list as an array index changing
   # in recent Numpy versions
   return data[tuple(__A     )]


__UpperCAmelCase      = TypeVar("""T""")





def 	snake_case_      (__A     :						Callable[[T], Any]					,   __A     :						Dict[Any, Union[dict, list, tuple, T]]					,   __A     :						Type[T]     )			->	Dict[Any, Union[dict, list, tuple, Any]]:
   __lowerCAmelCase  :			Dict[Any, Union[dict, list, tuple, Any]]					    =						{}
   for k, v in dic.items():
      if isinstance(__A					,   __A     ):
         __lowerCAmelCase  :			Any					    =						dict_map(__A					,   __A					,   __A     )
      else:
         __lowerCAmelCase  :			Optional[Any]					    =						tree_map(__A					,   __A					,   __A     )

   return new_dict





@overload
def 	snake_case_      (__A     :						Callable[[T], Any]					,   __A     :						T					,   __A     :						Type[T]     )			->	Any:
   ...





@overload
def 	snake_case_      (__A     :						Callable[[T], Any]					,   __A     :						dict					,   __A     :						Type[T]     )			->	dict:
   ...





@overload
def 	snake_case_      (__A     :						Callable[[T], Any]					,   __A     :						list					,   __A     :						Type[T]     )			->	list:
   ...





@overload
def 	snake_case_      (__A     :						Callable[[T], Any]					,   __A     :						tuple					,   __A     :						Type[T]     )			->	tuple:
   ...





def 	snake_case_      (__A     :						Optional[Any]					,   __A     :						List[str]					,   __A     :						Union[str, Any]     )			->	List[Any]:
   if isinstance(__A					,   __A     ):
      return dict_map(__A					,   __A					,   __A     )
   elif isinstance(__A					,   __A     ):
      return [tree_map(__A					,   __A					,   __A     ) for x in tree]
   elif isinstance(__A					,   __A     ):
      return tuple(tree_map(__A					,   __A					,   __A     ) for x in tree     )
   elif isinstance(__A					,   __A     ):
      return fn(__A     )
   else:
      print(type(__A     )     )
      raise ValueError("""Not supported"""     )
__UpperCAmelCase      = partial(tree_map, leaf_type=torch.Tensor)










"""simple docstring"""







def 						lowercase__(A = 1_000						)				->int:




						"""simple docstring"""



						lowercase__				:      Any=       [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[str]=       [0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

						lowercase__				:      Dict=       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())))






