






"""simple docstring"""







import random
import unittest

import numpy as np
import torch

from diffusers import DDIMScheduler, LDMSuperResolutionPipeline, UNetaDModel, VQModel
from diffusers.utils import PIL_INTERPOLATION, floats_tensor, load_image, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch


enable_full_determinism()


class     __UpperCAmelCase(   unittest.TestCase							):




						"""simple docstring"""




						@property
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      Tuple=       1
												lowercase__				:      Tuple=       3
												lowercase__				:      Any=       (32, 32)

												lowercase__				:      List[str]=       floats_tensor((batch_size, num_channels) + sizes       ,  rng=random.Random(0			)			).to(snake_case__			)
												return image




						@property
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												torch.manual_seed(0			)
												lowercase__				:      Dict=       UNetaDModel(
												    block_out_channels=(32, 64)       ,  layers_per_block=2       ,  sample_size=32       ,  in_channels=6       ,  out_channels=3       ,  down_block_types=("DownBlock2D", "AttnDownBlock2D")       ,  up_block_types=("AttnUpBlock2D", "UpBlock2D")       ,  )
												return model




						@property
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												torch.manual_seed(0			)
												lowercase__				:      str=       VQModel(
												    block_out_channels=[32, 64]       ,  in_channels=3       ,  out_channels=3       ,  down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]       ,  up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]       ,  latent_channels=3       ,  )
												return model




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      List[str]=       "cpu"
												lowercase__				:      List[Any]=       self.dummy_uncond_unet
												lowercase__				:      int=       DDIMScheduler()
												lowercase__				:      Dict=       self.dummy_vq_model

												lowercase__				:      List[str]=       LDMSuperResolutionPipeline(unet=snake_case__       ,  vqvae=snake_case__       ,  scheduler=snake_case__			)
												ldm.to(snake_case__			)
												ldm.set_progress_bar_config(disable=snake_case__			)

												lowercase__				:      Optional[int]=       self.dummy_image.to(snake_case__			)

												lowercase__				:      List[str]=       torch.Generator(device=snake_case__			).manual_seed(0			)
												lowercase__				:      Dict=       ldm(image=snake_case__       ,  generator=snake_case__       ,  num_inference_steps=2       ,  output_type="numpy"			).images

												lowercase__				:      Union[str, Any]=       image[0, -3:, -3:, -1]

												assert image.shape == (1, 64, 64, 3)
												lowercase__				:      Tuple=       np.array([0.86_78, 0.82_45, 0.63_81, 0.68_30, 0.43_85, 0.55_99, 0.46_41, 0.62_01, 0.51_50]			)

												assert np.abs(image_slice.flatten() - expected_slice			).max() < 1e-2




						@unittest.skipIf(torch_device != "cuda"       ,  "This test requires a GPU"			)
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      str=       self.dummy_uncond_unet
												lowercase__				:      str=       DDIMScheduler()
												lowercase__				:      int=       self.dummy_vq_model

												# put models in fp16
												lowercase__				:      List[Any]=       unet.half()
												lowercase__				:      int=       vqvae.half()

												lowercase__				:      List[Any]=       LDMSuperResolutionPipeline(unet=snake_case__       ,  vqvae=snake_case__       ,  scheduler=snake_case__			)
												ldm.to(snake_case__			)
												ldm.set_progress_bar_config(disable=snake_case__			)

												lowercase__				:      Any=       self.dummy_image.to(snake_case__			)

												lowercase__				:      Optional[Any]=       ldm(snake_case__       ,  num_inference_steps=2       ,  output_type="numpy"			).images

												assert image.shape == (1, 64, 64, 3)


@slow
@require_torch
class     __UpperCAmelCase(   unittest.TestCase							):




						"""simple docstring"""




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      Union[str, Any]=       load_image(
												    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
												    "/vq_diffusion/teddy_bear_pool.png"			)
												lowercase__				:      List[Any]=       init_image.resize((64, 64)       ,  resample=PIL_INTERPOLATION["lanczos"]			)

												lowercase__				:      List[str]=       LDMSuperResolutionPipeline.from_pretrained("duongna/ldm-super-resolution"       ,  device_map="auto"			)
												ldm.set_progress_bar_config(disable=snake_case__			)

												lowercase__				:      Dict=       torch.manual_seed(0			)
												lowercase__				:      int=       ldm(image=snake_case__       ,  generator=snake_case__       ,  num_inference_steps=20       ,  output_type="numpy"			).images

												lowercase__				:      int=       image[0, -3:, -3:, -1]

												assert image.shape == (1, 256, 256, 3)
												lowercase__				:      Optional[Any]=       np.array([0.76_44, 0.76_79, 0.76_42, 0.76_33, 0.76_66, 0.75_60, 0.74_25, 0.72_57, 0.69_07]			)

												assert np.abs(image_slice.flatten() - expected_slice			).max() < 1e-2














"""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())))






