


'''simple docstring'''


import colorsys
import io

import cva
import matplotlib as mpl
import matplotlib.colors as mplc
import matplotlib.figure as mplfigure
import numpy as np
import torch
from matplotlib.backends.backend_agg import FigureCanvasAgg

from utils import img_tensorize


UpperCAmelCase_		:       Optional[Any]							       =		1000





class    lowercase__  :





							'''simple docstring'''


							def __init__(   self   , __snake_case   , __snake_case=1.2   , __snake_case="g"   , __snake_case=0.5   , __snake_case="-"   , __snake_case="test_out.jpg"   , __snake_case=True   , __snake_case=False   , __snake_case=None   , __snake_case=None   , __snake_case=0.7   , ):
											if isinstance(UpperCamelCase__   , torch.Tensor  ):
															_SCREAMING_SNAKE_CASE			:	int							=				img.numpy().astype("""np.uint8"""  )
											if isinstance(UpperCamelCase__   , UpperCamelCase__  ):
															_SCREAMING_SNAKE_CASE			:	Optional[int]							=				img_tensorize(UpperCamelCase__  )
											assert isinstance(UpperCamelCase__   , np.ndarray  )

											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				img.shape[1], img.shape[0]
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				mplfigure.Figure(frameon=UpperCamelCase__  )
											_SCREAMING_SNAKE_CASE			:	Tuple							=				fig.get_dpi()
											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				(width * scale + 1e-2) / dpi
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				(height * scale + 1e-2) / dpi
											fig.set_size_inches(UpperCamelCase__   , UpperCamelCase__  )
											_SCREAMING_SNAKE_CASE			:	List[str]							=				fig.add_axes([0.0, 0.0, 1.0, 1.0]  )
											ax.axis("""off"""  )
											ax.set_xlim(0.0   , UpperCamelCase__  )
											ax.set_ylim(UpperCamelCase__  )

											_SCREAMING_SNAKE_CASE			:	str							=				saveas
											_SCREAMING_SNAKE_CASE			:	List[str]							=				rgb
											_SCREAMING_SNAKE_CASE			:	int							=				pynb
											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				img
											_SCREAMING_SNAKE_CASE			:	List[str]							=				edgecolor
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				0.5
											_SCREAMING_SNAKE_CASE			:	List[str]							=				linestyle
											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				int(np.sqrt(min(UpperCamelCase__   , UpperCamelCase__  )  ) * scale // 3  )
											_SCREAMING_SNAKE_CASE			:	int							=				width
											_SCREAMING_SNAKE_CASE			:	str							=				height
											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				scale
											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				fig
											_SCREAMING_SNAKE_CASE			:	List[Any]							=				ax
											_SCREAMING_SNAKE_CASE			:	List[Any]							=				pad
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				idaobj
											_SCREAMING_SNAKE_CASE			:	Dict							=				idaattr
											_SCREAMING_SNAKE_CASE			:	Any							=				FigureCanvasAgg(UpperCamelCase__  )






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case=None  ):
											if color is None:
															_SCREAMING_SNAKE_CASE			:	Tuple							=				self.edgecolor
											(_SCREAMING_SNAKE_CASE)			:	Optional[Any]							=				box
											_SCREAMING_SNAKE_CASE			:	Tuple							=				xa - xa
											_SCREAMING_SNAKE_CASE			:	List[str]							=				ya - ya
											self.ax.add_patch(
											    mpl.patches.Rectangle(
											        (xa, ya)   , UpperCamelCase__   , UpperCamelCase__   , fill=UpperCamelCase__   , edgecolor=UpperCamelCase__   , linewidth=self.font_size // 3   , alpha=self.alpha   , linestyle=self.linestyle   , )  )






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case=None   , __snake_case=None   , __snake_case=None   , __snake_case=None  ):
											if len(boxes.shape  ) > 2:
															_SCREAMING_SNAKE_CASE			:	List[str]							=				boxes[0]
											if len(obj_ids.shape  ) > 1:
															_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				obj_ids[0]
											if len(obj_scores.shape  ) > 1:
															_SCREAMING_SNAKE_CASE			:	Tuple							=				obj_scores[0]
											if len(attr_ids.shape  ) > 1:
															_SCREAMING_SNAKE_CASE			:	Tuple							=				attr_ids[0]
											if len(attr_scores.shape  ) > 1:
															_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				attr_scores[0]
											if isinstance(UpperCamelCase__   , torch.Tensor  ):
															_SCREAMING_SNAKE_CASE			:	Dict							=				boxes.numpy()
											if isinstance(UpperCamelCase__   , UpperCamelCase__  ):
															_SCREAMING_SNAKE_CASE			:	int							=				np.array(UpperCamelCase__  )
											assert isinstance(UpperCamelCase__   , np.ndarray  )
											_SCREAMING_SNAKE_CASE			:	str							=				np.prod(boxes[:, 2:] - boxes[:, :2]   , axis=1  )
											_SCREAMING_SNAKE_CASE			:	List[Any]							=				np.argsort(-areas  ).tolist()
											_SCREAMING_SNAKE_CASE			:	str							=				boxes[sorted_idxs] if boxes is not None else None
											_SCREAMING_SNAKE_CASE			:	List[str]							=				obj_ids[sorted_idxs] if obj_ids is not None else None
											_SCREAMING_SNAKE_CASE			:	List[Any]							=				obj_scores[sorted_idxs] if obj_scores is not None else None
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				attr_ids[sorted_idxs] if attr_ids is not None else None
											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				attr_scores[sorted_idxs] if attr_scores is not None else None

											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				[self._random_color(maximum=1  ) for _ in range(len(UpperCamelCase__  )  )]
											_SCREAMING_SNAKE_CASE			:	List[str]							=				[assigned_colors[idx] for idx in sorted_idxs]
											if obj_ids is not None:
															_SCREAMING_SNAKE_CASE			:	Any							=				self._create_text_labels_attr(UpperCamelCase__   , UpperCamelCase__   , UpperCamelCase__   , UpperCamelCase__  )
															for i in range(len(UpperCamelCase__  )  ):
																			_SCREAMING_SNAKE_CASE			:	Any							=				assigned_colors[i]
																			self.add_box(boxes[i]   , UpperCamelCase__  )
																			self.draw_labels(labels[i]   , boxes[i]   , UpperCamelCase__  )






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case   , __snake_case  ):
											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				box
											_SCREAMING_SNAKE_CASE			:	int							=				(xa, ya)
											_SCREAMING_SNAKE_CASE			:	Tuple							=				(ya - ya) * (xa - xa)
											_SCREAMING_SNAKE_CASE			:	Dict							=				_SMALL_OBJ * self.scale
											if instance_area < small or ya - ya < 40 * self.scale:
															if ya >= self.height - 5:
																			_SCREAMING_SNAKE_CASE			:	Dict							=				(xa, ya)
															else:
																			_SCREAMING_SNAKE_CASE			:	List[str]							=				(xa, ya)

											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				(ya - ya) / np.sqrt(self.height * self.width  )
											_SCREAMING_SNAKE_CASE			:	Dict							=				self._change_color_brightness(UpperCamelCase__   , brightness_factor=0.7  )
											_SCREAMING_SNAKE_CASE			:	str							=				np.clip((height_ratio - 0.02) / 0.08 + 1   , 1.2   , 2  )
											font_size *= 0.75 * self.font_size

											self.draw_text(
											    text=UpperCamelCase__   , position=UpperCamelCase__   , color=UpperCamelCase__   , )






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case   , __snake_case="g"   , __snake_case="left"   , ):
											_SCREAMING_SNAKE_CASE			:	Any							=				0
											_SCREAMING_SNAKE_CASE			:	int							=				self.font_size
											_SCREAMING_SNAKE_CASE			:	Tuple							=				np.maximum(list(mplc.to_rgb(UpperCamelCase__  )  )   , 0.2  )
											_SCREAMING_SNAKE_CASE			:	Dict							=				max(0.8   , np.max(UpperCamelCase__  )  )
											_SCREAMING_SNAKE_CASE			:	Tuple							=				{
											    "facecolor": "black",
											    "alpha": self.alpha,
											    "pad": self.pad,
											    "edgecolor": "none",
											}
											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				position
											self.ax.text(
											    UpperCamelCase__   , UpperCamelCase__   , UpperCamelCase__   , size=font_size * self.scale   , family="""sans-serif"""   , bbox=UpperCamelCase__   , verticalalignment="""top"""   , horizontalalignment=UpperCamelCase__   , color=UpperCamelCase__   , zorder=10   , rotation=UpperCamelCase__   , )






							def UpperCAmelCase_     (   self   , __snake_case=None  ):
											if saveas is None:
															_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				self.saveas
											if saveas.lower().endswith(""".jpg"""  ) or saveas.lower().endswith(""".png"""  ):
															cva.imwrite(
															    UpperCamelCase__   , self._get_buffer()[:, :, ::-1]   , )
											else:
															self.fig.savefig(UpperCamelCase__  )






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case   , __snake_case   , __snake_case  ):
											_SCREAMING_SNAKE_CASE			:	Any							=				[self.idaobj[i] for i in classes]
											_SCREAMING_SNAKE_CASE			:	List[str]							=				[self.idaattr[i] for i in attr_classes]
											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				[
											    f"""{label} {score:.2f} {attr} {attr_score:.2f}"""
											    for label, score, attr, attr_score in zip(UpperCamelCase__   , UpperCamelCase__   , UpperCamelCase__   , UpperCamelCase__  )
											]
											return labels






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case  ):
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				[self.idaobj[i] for i in classes]
											if scores is not None:
															if labels is None:
																			_SCREAMING_SNAKE_CASE			:	Any							=				["{:.0f}%".format(s * 100  ) for s in scores]
															else:
																			_SCREAMING_SNAKE_CASE			:	Dict							=				["{} {:.0f}%".format(UpperCamelCase__   , s * 100  ) for li, s in zip(UpperCamelCase__   , UpperCamelCase__  )]
											return labels






							def UpperCAmelCase_     (   self   , __snake_case=255  ):
											_SCREAMING_SNAKE_CASE			:	Tuple							=				np.random.randint(0   , len(_COLORS  )  )
											_SCREAMING_SNAKE_CASE			:	List[Any]							=				_COLORS[idx] * maximum
											if not self.rgb:
															_SCREAMING_SNAKE_CASE			:	Dict							=				ret[::-1]
											return ret






							def UpperCAmelCase_     (   self  ):
											if not self.pynb:
															_SCREAMING_SNAKE_CASE			:	str							=				self.canvas.print_to_buffer()
															if (width, height) != (self.width, self.height):
																			_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				cva.resize(self.img   , (width, height)  )
															else:
																			_SCREAMING_SNAKE_CASE			:	List[str]							=				self.img
											else:
															_SCREAMING_SNAKE_CASE			:	str							=				io.BytesIO()  # works for cairo backend
															self.canvas.print_rgba(UpperCamelCase__  )
															_SCREAMING_SNAKE_CASE			:	Tuple							=				self.width, self.height
															_SCREAMING_SNAKE_CASE			:	List[Any]							=				buf.getvalue()
															_SCREAMING_SNAKE_CASE			:	int							=				self.img

											_SCREAMING_SNAKE_CASE			:	List[Any]							=				np.frombuffer(UpperCamelCase__   , dtype="""uint8"""  )
											_SCREAMING_SNAKE_CASE			:	Any							=				buffer.reshape(UpperCamelCase__   , UpperCamelCase__   , 4  )
											_SCREAMING_SNAKE_CASE			:	Any							=				np.split(UpperCamelCase__   , [3]   , axis=2  )

											try:
															import numexpr as ne  # fuse them with numexpr

															_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				ne.evaluate("""img * (1 - alpha / 255.0) + rgb * (alpha / 255.0)"""  )
											except ImportError:
															_SCREAMING_SNAKE_CASE			:	Optional[int]							=				alpha.astype("""float32"""  ) / 255.0
															_SCREAMING_SNAKE_CASE			:	List[Any]							=				img * (1 - alpha) + rgb * alpha

											return visualized_image.astype("""uint8"""  )






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case  ):
											assert brightness_factor >= -1.0 and brightness_factor <= 1.0
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				mplc.to_rgb(UpperCamelCase__  )
											_SCREAMING_SNAKE_CASE			:	Dict							=				colorsys.rgb_to_hls(*mplc.to_rgb(UpperCamelCase__  )  )
											_SCREAMING_SNAKE_CASE			:	Dict							=				polygon_color[1] + (brightness_factor * polygon_color[1])
											_SCREAMING_SNAKE_CASE			:	List[str]							=				0.0 if modified_lightness < 0.0 else modified_lightness
											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				1.0 if modified_lightness > 1.0 else modified_lightness
											_SCREAMING_SNAKE_CASE			:	Dict							=				colorsys.hls_to_rgb(polygon_color[0]   , UpperCamelCase__   , polygon_color[2]  )
											return modified_color



UpperCAmelCase_		:       List[str]							       =		(
    np.array(
        [
            0.000,
            0.447,
            0.741,
            0.850,
            0.325,
            0.098,
            0.929,
            0.694,
            0.125,
            0.494,
            0.184,
            0.556,
            0.466,
            0.674,
            0.188,
            0.301,
            0.745,
            0.933,
            0.635,
            0.078,
            0.184,
            0.300,
            0.300,
            0.300,
            0.600,
            0.600,
            0.600,
            1.000,
            0.000,
            0.000,
            1.000,
            0.500,
            0.000,
            0.749,
            0.749,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            1.000,
            0.667,
            0.000,
            1.000,
            0.333,
            0.333,
            0.000,
            0.333,
            0.667,
            0.000,
            0.333,
            1.000,
            0.000,
            0.667,
            0.333,
            0.000,
            0.667,
            0.667,
            0.000,
            0.667,
            1.000,
            0.000,
            1.000,
            0.333,
            0.000,
            1.000,
            0.667,
            0.000,
            1.000,
            1.000,
            0.000,
            0.000,
            0.333,
            0.500,
            0.000,
            0.667,
            0.500,
            0.000,
            1.000,
            0.500,
            0.333,
            0.000,
            0.500,
            0.333,
            0.333,
            0.500,
            0.333,
            0.667,
            0.500,
            0.333,
            1.000,
            0.500,
            0.667,
            0.000,
            0.500,
            0.667,
            0.333,
            0.500,
            0.667,
            0.667,
            0.500,
            0.667,
            1.000,
            0.500,
            1.000,
            0.000,
            0.500,
            1.000,
            0.333,
            0.500,
            1.000,
            0.667,
            0.500,
            1.000,
            1.000,
            0.500,
            0.000,
            0.333,
            1.000,
            0.000,
            0.667,
            1.000,
            0.000,
            1.000,
            1.000,
            0.333,
            0.000,
            1.000,
            0.333,
            0.333,
            1.000,
            0.333,
            0.667,
            1.000,
            0.333,
            1.000,
            1.000,
            0.667,
            0.000,
            1.000,
            0.667,
            0.333,
            1.000,
            0.667,
            0.667,
            1.000,
            0.667,
            1.000,
            1.000,
            1.000,
            0.000,
            1.000,
            1.000,
            0.333,
            1.000,
            1.000,
            0.667,
            1.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.167,
            0.000,
            0.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.167,
            0.000,
            0.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.143,
            0.143,
            0.143,
            0.857,
            0.857,
            0.857,
            1.000,
            1.000,
            1.000,
        ]
    )
    .astype(np.floataa)
    .reshape(-1, 3)
)








'''simple docstring'''


def       snake_case_       (  SCREAMING_SNAKE_CASE__ = 1000					):







				"""simple docstring"""





				_SCREAMING_SNAKE_CASE			:	Union[str, 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)
				_SCREAMING_SNAKE_CASE			:	str							=				[0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

				_SCREAMING_SNAKE_CASE			:	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())))




