


'''simple docstring'''


from typing import Optional, Tuple

import flax.linen as nn
import jax
import jax.numpy as jnp
from configuration_hybrid_clip import HybridCLIPConfig
from flax.core.frozen_dict import FrozenDict

from transformers import FLAX_MODEL_MAPPING, FlaxCLIPVisionModel
from transformers.modeling_flax_utils import FlaxPreTrainedModel
from transformers.models.clip.modeling_flax_clip import FlaxCLIPOutput
from transformers.utils import logging


UpperCAmelCase_		:       Optional[int]							       =		logging.get_logger(__name__)





class    lowercase__  (						nn.Module ):





							'''simple docstring'''


							A_							:				HybridCLIPConfig
							A_							:				jnp.dtype				     =  jnp.floataa






							def UpperCAmelCase_     (   self  ):
											_SCREAMING_SNAKE_CASE			:	str							=				self.config.text_config
											_SCREAMING_SNAKE_CASE			:	Dict							=				self.config.vision_config

											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				self.config.projection_dim
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				text_config.hidden_size
											_SCREAMING_SNAKE_CASE			:	str							=				vision_config.hidden_size

											_SCREAMING_SNAKE_CASE			:	Tuple							=				FLAX_MODEL_MAPPING[self.config.text_config.__class__].module_class
											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				FLAX_MODEL_MAPPING.get(self.config.vision_config.__class__   , _UpperCamelCase  ).module_class

											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				text_module(_UpperCamelCase   , dtype=self.dtype  )
											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				vision_module(_UpperCamelCase   , dtype=self.dtype  )

											_SCREAMING_SNAKE_CASE			:	str							=				nn.Dense(
											    self.projection_dim   , dtype=self.dtype   , kernel_init=jax.nn.initializers.normal(0.02  )   , use_bias=_UpperCamelCase   , )
											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				nn.Dense(
											    self.projection_dim   , dtype=self.dtype   , kernel_init=jax.nn.initializers.normal(0.02  )   , use_bias=_UpperCamelCase   , )
											_SCREAMING_SNAKE_CASE			:	List[str]							=				self.param("""logit_scale"""   , jax.nn.initializers.ones   , []  )






							def __call__(   self   , __snake_case=None   , __snake_case=None   , __snake_case=None   , __snake_case=None   , __snake_case=None   , __snake_case = True   , __snake_case=None   , __snake_case=None   , __snake_case=None   , ):
											_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				return_dict if return_dict is not None else self.config.return_dict

											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				self.vision_model(
											    pixel_values=_UpperCamelCase   , deterministic=_UpperCamelCase   , output_attentions=_UpperCamelCase   , output_hidden_states=_UpperCamelCase   , return_dict=_UpperCamelCase   , )

											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				self.text_model(
											    input_ids=_UpperCamelCase   , attention_mask=_UpperCamelCase   , token_type_ids=_UpperCamelCase   , position_ids=_UpperCamelCase   , deterministic=_UpperCamelCase   , output_attentions=_UpperCamelCase   , output_hidden_states=_UpperCamelCase   , return_dict=_UpperCamelCase   , )

											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				vision_outputs[1]
											_SCREAMING_SNAKE_CASE			:	Tuple							=				self.visual_projection(_UpperCamelCase  )

											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				text_outputs[1]
											_SCREAMING_SNAKE_CASE			:	int							=				self.text_projection(_UpperCamelCase  )

											# normalized features
											_SCREAMING_SNAKE_CASE			:	List[Any]							=				image_embeds / jnp.linalg.norm(_UpperCamelCase   , axis=-1   , keepdims=_UpperCamelCase  )
											_SCREAMING_SNAKE_CASE			:	Tuple							=				text_embeds / jnp.linalg.norm(_UpperCamelCase   , axis=-1   , keepdims=_UpperCamelCase  )

											# cosine similarity as logits
											_SCREAMING_SNAKE_CASE			:	Dict							=				jnp.exp(self.logit_scale  )
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				jnp.matmul(_UpperCamelCase   , image_embeds.T  ) * logit_scale
											_SCREAMING_SNAKE_CASE			:	Any							=				logits_per_text.T

											if not return_dict:
															return (logits_per_image, logits_per_text, text_embeds, image_embeds, text_outputs, vision_outputs)

											return FlaxCLIPOutput(
											    logits_per_image=_UpperCamelCase   , logits_per_text=_UpperCamelCase   , text_embeds=_UpperCamelCase   , image_embeds=_UpperCamelCase   , text_model_output=_UpperCamelCase   , vision_model_output=_UpperCamelCase   , )





class    lowercase__  (						__lowerCamelCase ):





							'''simple docstring'''


							A_							:				Tuple				     =  HybridCLIPConfig
							A_							:				Optional[int]				     =  FlaxHybridCLIPModule






							def __init__(   self   , __snake_case   , __snake_case = None   , __snake_case = 0   , __snake_case = jnp.floataa   , **__snake_case   , ):





											if input_shape is None:
															_SCREAMING_SNAKE_CASE			:	Tuple							=				((1, 1), (1, config.vision_config.image_size, config.vision_config.image_size, 3))

											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				self.module_class(config=_UpperCamelCase   , dtype=_UpperCamelCase   , **_UpperCamelCase  )
											super().__init__(_UpperCamelCase   , _UpperCamelCase   , input_shape=_UpperCamelCase   , seed=_UpperCamelCase   , dtype=_UpperCamelCase  )






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case   , __snake_case = None  ):
											_SCREAMING_SNAKE_CASE			:	List[str]							=				jnp.zeros(input_shape[0]   , dtype="""i4"""  )
											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				jnp.broadcast_to(jnp.arange(jnp.atleast_ad(_UpperCamelCase  ).shape[-1]  )   , input_shape[0]  )
											_SCREAMING_SNAKE_CASE			:	List[Any]							=				jnp.ones_like(_UpperCamelCase  )
											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				jnp.ones_like(_UpperCamelCase  )

											_SCREAMING_SNAKE_CASE			:	str							=				jax.random.normal(_UpperCamelCase   , input_shape[1]  )

											_SCREAMING_SNAKE_CASE		,	_SCREAMING_SNAKE_CASE			:	Tuple							=				jax.random.split(_UpperCamelCase  )
											_SCREAMING_SNAKE_CASE			:	List[Any]							=				{"""params""": params_rng, """dropout""": dropout_rng}

											return self.module.init(_UpperCamelCase   , _UpperCamelCase   , _UpperCamelCase   , _UpperCamelCase   , _UpperCamelCase   , _UpperCamelCase  )["params"]






							def __call__(   self   , __snake_case   , __snake_case   , __snake_case=None   , __snake_case=None   , __snake_case=None   , __snake_case = None   , __snake_case = None   , __snake_case = False   , __snake_case = None   , __snake_case = None   , __snake_case = None   , ):
											_SCREAMING_SNAKE_CASE			:	int							=				output_attentions if output_attentions is not None else self.config.output_attentions
											_SCREAMING_SNAKE_CASE			:	int							=				(
											    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
											)
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				return_dict if return_dict is not None else self.config.return_dict

											if position_ids is None:
															_SCREAMING_SNAKE_CASE			:	List[str]							=				jnp.broadcast_to(jnp.arange(jnp.atleast_ad(_UpperCamelCase  ).shape[-1]  )   , input_ids.shape  )

											if token_type_ids is None:
															_SCREAMING_SNAKE_CASE			:	List[str]							=				jnp.zeros_like(_UpperCamelCase  )

											if attention_mask is None:
															_SCREAMING_SNAKE_CASE			:	Any							=				jnp.ones_like(_UpperCamelCase  )

											# Handle any PRNG if needed
											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				{}
											if dropout_rng is not None:
															_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				dropout_rng

											return self.module.apply(
											    {"""params""": params or self.params}   , jnp.array(_UpperCamelCase   , dtype="""i4"""  )   , jnp.array(_UpperCamelCase   , dtype=jnp.floataa  )   , jnp.array(_UpperCamelCase   , dtype="""i4"""  )   , jnp.array(_UpperCamelCase   , dtype="""i4"""  )   , jnp.array(_UpperCamelCase   , dtype="""i4"""  )   , not train   , _UpperCamelCase   , _UpperCamelCase   , _UpperCamelCase   , rngs=_UpperCamelCase   , )






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case=None   , __snake_case=None   , __snake_case=None   , __snake_case = None   , __snake_case = None   , __snake_case=False   , ):





											if position_ids is None:
															_SCREAMING_SNAKE_CASE			:	Any							=				jnp.broadcast_to(jnp.arange(jnp.atleast_ad(_UpperCamelCase  ).shape[-1]  )   , input_ids.shape  )

											if token_type_ids is None:
															_SCREAMING_SNAKE_CASE			:	Dict							=				jnp.zeros_like(_UpperCamelCase  )

											if attention_mask is None:
															_SCREAMING_SNAKE_CASE			:	List[Any]							=				jnp.ones_like(_UpperCamelCase  )

											# Handle any PRNG if needed
											_SCREAMING_SNAKE_CASE			:	Optional[int]							=				{}
											if dropout_rng is not None:
															_SCREAMING_SNAKE_CASE			:	List[Any]							=				dropout_rng

											def _get_features(__snake_case   , __snake_case   , __snake_case   , __snake_case   , __snake_case   , __snake_case  ):
															_SCREAMING_SNAKE_CASE			:	Any							=				module.text_model(
															    input_ids=_UpperCamelCase   , attention_mask=_UpperCamelCase   , position_ids=_UpperCamelCase   , token_type_ids=_UpperCamelCase   , deterministic=_UpperCamelCase   , )
															_SCREAMING_SNAKE_CASE			:	List[Any]							=				text_outputs[1]
															_SCREAMING_SNAKE_CASE			:	List[Any]							=				module.text_projection(_UpperCamelCase  )
															return text_features

											return self.module.apply(
											    {"""params""": params or self.params}   , jnp.array(_UpperCamelCase   , dtype="""i4"""  )   , jnp.array(_UpperCamelCase   , dtype="""i4"""  )   , jnp.array(_UpperCamelCase   , dtype="""i4"""  )   , jnp.array(_UpperCamelCase   , dtype="""i4"""  )   , not train   , method=_get_features   , rngs=_UpperCamelCase   , )






							def UpperCAmelCase_     (   self   , __snake_case   , __snake_case = None   , __snake_case = None   , __snake_case=False  ):
											_SCREAMING_SNAKE_CASE			:	Dict							=				{}
											if dropout_rng is not None:
															_SCREAMING_SNAKE_CASE			:	Optional[int]							=				dropout_rng

											def _get_features(__snake_case   , __snake_case   , __snake_case  ):
															_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				module.vision_model(pixel_values=_UpperCamelCase   , deterministic=_UpperCamelCase  )
															_SCREAMING_SNAKE_CASE			:	Tuple							=				vision_outputs[1]  # pooled_output
															_SCREAMING_SNAKE_CASE			:	List[Any]							=				module.visual_projection(_UpperCamelCase  )
															return image_features

											return self.module.apply(
											    {"""params""": params or self.params}   , jnp.array(_UpperCamelCase   , dtype=jnp.floataa  )   , not train   , method=_get_features   , rngs=_UpperCamelCase   , )






							@classmethod
							def UpperCAmelCase_     (   cls   , __snake_case = None   , __snake_case = None   , *__snake_case   , **__snake_case   , ):
											_SCREAMING_SNAKE_CASE			:	Dict							=				{
											    argument[len("""text_"""  ) :]: value for argument, value in kwargs.items() if argument.startswith("""text_"""  )
											}

											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				{
											    argument[len("""vision_"""  ) :]: value for argument, value in kwargs.items() if argument.startswith("""vision_"""  )
											}

											# remove text, vision kwargs from kwargs
											for key in kwargs_text.keys():
															del kwargs["text_" + key]
											for key in kwargs_vision.keys():
															del kwargs["vision_" + key]

											# Load and initialize the text and vision model
											_SCREAMING_SNAKE_CASE			:	Dict							=				kwargs_text.pop("""model"""   , _UpperCamelCase  )
											if text_model is None:
															assert (
															    text_model_name_or_path is not None
															), "If `model` is not defined as an argument, a `text_model_name_or_path` has to be defined"
															from transformers import FlaxAutoModel

															if "config" not in kwargs_text:
																			from transformers import AutoConfig

																			_SCREAMING_SNAKE_CASE			:	Tuple							=				AutoConfig.from_pretrained(_UpperCamelCase  )
																			_SCREAMING_SNAKE_CASE			:	Union[str, Any]							=				text_config

															_SCREAMING_SNAKE_CASE			:	int							=				FlaxAutoModel.from_pretrained(_UpperCamelCase   , *_UpperCamelCase   , **_UpperCamelCase  )

											_SCREAMING_SNAKE_CASE			:	Any							=				kwargs_vision.pop("""model"""   , _UpperCamelCase  )
											if vision_model is None:
															assert (
															    vision_model_name_or_path is not None
															), "If `model` is not defined as an argument, a `vision_model_name_or_path` has to be defined"
															from transformers import FlaxAutoModel

															if "config" not in kwargs_vision:
																			from transformers import AutoConfig

																			_SCREAMING_SNAKE_CASE			:	Optional[int]							=				AutoConfig.from_pretrained(_UpperCamelCase  )
																			_SCREAMING_SNAKE_CASE			:	int							=				vision_config

															_SCREAMING_SNAKE_CASE			:	Optional[int]							=				FlaxAutoModel.from_pretrained(_UpperCamelCase   , *_UpperCamelCase   , **_UpperCamelCase  )

											# instantiate config with corresponding kwargs
											_SCREAMING_SNAKE_CASE			:	str							=				kwargs.pop("""dtype"""   , jnp.floataa  )
											_SCREAMING_SNAKE_CASE			:	str							=				HybridCLIPConfig.from_text_vision_configs(text_model.config   , vision_model.config   , **_UpperCamelCase  )

											# init model
											_SCREAMING_SNAKE_CASE			:	Tuple							=				cls(_UpperCamelCase   , *_UpperCamelCase   , dtype=_UpperCamelCase   , **_UpperCamelCase  )

											if vision_config.model_type == "clip":
															_SCREAMING_SNAKE_CASE			:	List[str]							=				vision_model.params["""vision_model"""]
															_SCREAMING_SNAKE_CASE			:	Dict							=				vision_model.params["""visual_projection"""]["""kernel"""]
											else:
															_SCREAMING_SNAKE_CASE			:	Optional[int]							=				vision_model.params

											_SCREAMING_SNAKE_CASE			:	Optional[Any]							=				text_model.params

											return model








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




