import unittest

from transformers import SpeechaTextaConfig
from transformers.testing_utils import is_torch_available, require_torch, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch

							from transformers.models.speech_to_text_a.modeling_speech_to_text_a import (
							    SpeechaTextaDecoder,
							    SpeechaTextaForCausalLM,
							)


@require_torch
class   lowercase			:




							def __init__(  self      :    Tuple		,							_UpperCamelCase      :    Optional[Any]		,							_UpperCamelCase      :    Optional[Any]=99		,							_UpperCamelCase      :    Optional[Any]=13		,							_UpperCamelCase      :    Any=16		,							_UpperCamelCase      :    Any=7		,							_UpperCamelCase      :    List[str]=True		,							_UpperCamelCase      :    Tuple=True		,							_UpperCamelCase      :    int=True		,							_UpperCamelCase      :    int=False		,							_UpperCamelCase      :    str=True		,							_UpperCamelCase      :    Optional[int]=2		,							_UpperCamelCase      :    int=32		,							_UpperCamelCase      :    str=4		,							_UpperCamelCase      :    int=4		,							_UpperCamelCase      :    Any=30		,							_UpperCamelCase      :    List[str]=0		,							_UpperCamelCase      :    List[Any]=1		,							_UpperCamelCase      :    Optional[Any]=2		,							_UpperCamelCase      :    Optional[int]=None		,							)    -> List[Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE				=				parent
												SCREAMING_SNAKE_CASE				=				batch_size
												SCREAMING_SNAKE_CASE				=				decoder_seq_length
												# For common tests
												SCREAMING_SNAKE_CASE				=				self.decoder_seq_length
												SCREAMING_SNAKE_CASE				=				is_training
												SCREAMING_SNAKE_CASE				=				use_attention_mask
												SCREAMING_SNAKE_CASE				=				use_labels

												SCREAMING_SNAKE_CASE				=				vocab_size
												SCREAMING_SNAKE_CASE				=				d_model
												SCREAMING_SNAKE_CASE				=				d_model
												SCREAMING_SNAKE_CASE				=				decoder_layers
												SCREAMING_SNAKE_CASE				=				decoder_layers
												SCREAMING_SNAKE_CASE				=				decoder_ffn_dim
												SCREAMING_SNAKE_CASE				=				decoder_attention_heads
												SCREAMING_SNAKE_CASE				=				decoder_attention_heads
												SCREAMING_SNAKE_CASE				=				eos_token_id
												SCREAMING_SNAKE_CASE				=				bos_token_id
												SCREAMING_SNAKE_CASE				=				pad_token_id
												SCREAMING_SNAKE_CASE				=				decoder_start_token_id
												SCREAMING_SNAKE_CASE				=				use_cache
												SCREAMING_SNAKE_CASE				=				max_position_embeddings

												SCREAMING_SNAKE_CASE				=				None
												SCREAMING_SNAKE_CASE				=				decoder_seq_length
												SCREAMING_SNAKE_CASE				=				2
												SCREAMING_SNAKE_CASE				=				1




							def 		__snake_case(  self      :    Optional[int]					)    -> str:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE				=				ids_tensor([self.batch_size, self.decoder_seq_length]		,							self.vocab_size					)

												SCREAMING_SNAKE_CASE				=				None
												if self.use_attention_mask:
																	SCREAMING_SNAKE_CASE				=				ids_tensor([self.batch_size, self.decoder_seq_length]		,							vocab_size=2					)

												SCREAMING_SNAKE_CASE				=				None
												if self.use_labels:
																	SCREAMING_SNAKE_CASE				=				ids_tensor([self.batch_size, self.decoder_seq_length]		,							self.vocab_size					)

												SCREAMING_SNAKE_CASE				=				SpeechaTextaConfig(
												    vocab_size=self.vocab_size		,							d_model=self.d_model		,							decoder_layers=self.decoder_layers		,							decoder_ffn_dim=self.decoder_ffn_dim		,							decoder_attention_heads=self.decoder_attention_heads		,							eos_token_id=self.eos_token_id		,							bos_token_id=self.bos_token_id		,							use_cache=self.use_cache		,							pad_token_id=self.pad_token_id		,							decoder_start_token_id=self.decoder_start_token_id		,							max_position_embeddings=self.max_position_embeddings		,							)

												return (
												    config,
												    input_ids,
												    attention_mask,
												    lm_labels,
												)




							def 		__snake_case(  self      :    Dict		,							_UpperCamelCase      :    Optional[Any]		,							_UpperCamelCase      :    Union[str, Any]		,							_UpperCamelCase      :    Union[str, Any]		,							_UpperCamelCase      :    Optional[Any]		,							)    -> Optional[Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE				=				True
												SCREAMING_SNAKE_CASE				=				SpeechaTextaDecoder(config=snake_case__					).to(snake_case__					).eval()
												SCREAMING_SNAKE_CASE				=				input_ids[:2]

												input_ids[input_ids == 0] += 1
												# first forward pass
												SCREAMING_SNAKE_CASE				=				model(snake_case__		,							use_cache=snake_case__					)
												SCREAMING_SNAKE_CASE				=				model(snake_case__					)
												SCREAMING_SNAKE_CASE				=				model(snake_case__		,							use_cache=snake_case__					)

												self.parent.assertTrue(len(snake_case__					) == len(snake_case__					)					)
												self.parent.assertTrue(len(snake_case__					) == len(snake_case__					) + 1					)

												SCREAMING_SNAKE_CASE				=				outputs["past_key_values"]

												# create hypothetical next token and extent to next_input_ids
												SCREAMING_SNAKE_CASE				=				ids_tensor((2, 1)		,							config.vocab_size - 1					) + 1

												# append to next input_ids and
												SCREAMING_SNAKE_CASE				=				torch.cat([input_ids, next_tokens]		,							dim=-1					)

												print(snake_case__					)

												SCREAMING_SNAKE_CASE				=				model(snake_case__					)["last_hidden_state"]
												SCREAMING_SNAKE_CASE				=				model(snake_case__		,							past_key_values=snake_case__					)["last_hidden_state"]

												# select random slice
												SCREAMING_SNAKE_CASE				=				ids_tensor((1,)		,							output_from_past.shape[-1]					).item()
												SCREAMING_SNAKE_CASE				=				output_from_no_past[:, next_input_ids.shape[-1] - 1, random_slice_idx].detach()
												SCREAMING_SNAKE_CASE				=				output_from_past[:, 0, random_slice_idx].detach()

												# test that outputs are equal for slice
												assert torch.allclose(snake_case__		,							snake_case__		,							atol=1e-3					)





							def 		__snake_case(  self      :    Optional[Any]					)    -> Dict:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE				=				self.prepare_config_and_inputs()
												(
												    SCREAMING_SNAKE_CASE	
												)				=				config_and_inputs

												SCREAMING_SNAKE_CASE				=				{
												    "input_ids": input_ids,
												    "attention_mask": attention_mask,
												}
												return config, inputs_dict



@require_torch
class   lowercase			(   SCREAMING_SNAKE_CASE__ ,				SCREAMING_SNAKE_CASE__ ,				SCREAMING_SNAKE_CASE__ ,				unittest.TestCase   ):
							lowercase__  :				Dict									=							(SpeechaTextaDecoder, SpeechaTextaForCausalLM) if is_torch_available() else ()
							lowercase__  :				List[Any]									=							(SpeechaTextaForCausalLM,) if is_torch_available() else ()
							lowercase__  :				Tuple									=							{"""text-generation""": SpeechaTextaForCausalLM} if is_torch_available() else {}
							lowercase__  :				int									=							True
							lowercase__  :				Union[str, Any]									=							False




							def 		__snake_case(  self      :    Optional[int]		,							)    -> Any:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE				=				SpeechaTextaStandaloneDecoderModelTester(self		,							is_training=snake_case__					)
												SCREAMING_SNAKE_CASE				=				ConfigTester(self		,							config_class=snake_case__					)




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



												'''simple docstring'''

												pass




							def 		__snake_case(  self      :    Optional[int]					)    -> List[Any]:



												'''simple docstring'''

												pass




							def 		__snake_case(  self      :    str					)    -> Tuple:



												'''simple docstring'''

												pass




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



												'''simple docstring'''

												self.config_tester.run_common_tests()




							def 		__snake_case(  self      :    List[str]					)    -> Tuple:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE				=				self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_decoder_model_past(*snake_case__					)





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



												'''simple docstring'''

												return












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






