


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 lowerCAmelCase_		:

 '''simple docstring'''

 def __init__(      self						, _UpperCAmelCase						, _UpperCAmelCase=99						, _UpperCAmelCase=13						, _UpperCAmelCase=16						, _UpperCAmelCase=7						, _UpperCAmelCase=True						, _UpperCAmelCase=True						, _UpperCAmelCase=True						, _UpperCAmelCase=False						, _UpperCAmelCase=True						, _UpperCAmelCase=2						, _UpperCAmelCase=32						, _UpperCAmelCase=4						, _UpperCAmelCase=4						, _UpperCAmelCase=30						, _UpperCAmelCase=0						, _UpperCAmelCase=1						, _UpperCAmelCase=2						, _UpperCAmelCase=None						, ):
       snake_case_			= parent
       snake_case_			= batch_size
       snake_case_			= decoder_seq_length
       # For common tests
       snake_case_			= self.decoder_seq_length
       snake_case_			= is_training
       snake_case_			= use_attention_mask
       snake_case_			= use_labels

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

       snake_case_			= None
       snake_case_			= decoder_seq_length
       snake_case_			= 2
       snake_case_			= 1



 def 		UpperCamelCase__	(      self   ):
       snake_case_			= ids_tensor([self.batch_size, self.decoder_seq_length]						, self.vocab_size   )

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

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

       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 		UpperCamelCase__	(      self						, _UpperCAmelCase						, _UpperCAmelCase						, _UpperCAmelCase						, _UpperCAmelCase						, ):
       snake_case_			= True
       snake_case_			= SpeechaTextaDecoder(config=_UpperCAmelCase   ).to(_UpperCAmelCase   ).eval()
       snake_case_			= input_ids[:2]

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

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

       snake_case_			= outputs['''past_key_values''']

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

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

       print(_UpperCAmelCase   )

       snake_case_			= model(_UpperCAmelCase   )['''last_hidden_state''']
       snake_case_			= model(_UpperCAmelCase						, past_key_values=_UpperCAmelCase   )['''last_hidden_state''']

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

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





 def 		UpperCamelCase__	(      self   ):
       snake_case_			= self.prepare_config_and_inputs()
       (
           (
           snake_case_
       )			,       (
           snake_case_
       )			,       (
           snake_case_
       )			,       (
           snake_case_
       )			,       
       )			= config_and_inputs

       snake_case_			= {
           '''input_ids''': input_ids,
           '''attention_mask''': attention_mask,
       }
       return config, inputs_dict







@require_torch
class lowerCAmelCase_		(					lowerCamelCase__   ,		lowerCamelCase__   ,		lowerCamelCase__   ,		unittest.TestCase			):

 '''simple docstring'''

 __snake_case				=    (SpeechaTextaDecoder, SpeechaTextaForCausalLM) if is_torch_available() else ()
 __snake_case				=    (SpeechaTextaForCausalLM,) if is_torch_available() else ()
 __snake_case				=    {"text-generation": SpeechaTextaForCausalLM} if is_torch_available() else {}
 __snake_case				=    True
 __snake_case				=    False



 def 		UpperCamelCase__	(      self						, ):
       snake_case_			= SpeechaTextaStandaloneDecoderModelTester(self						, is_training=_UpperCAmelCase   )
       snake_case_			= ConfigTester(self						, config_class=_UpperCAmelCase   )



 def 		UpperCamelCase__	(      self   ):
       pass



 def 		UpperCamelCase__	(      self   ):
       pass



 def 		UpperCamelCase__	(      self   ):
       pass



 def 		UpperCamelCase__	(      self   ):
       self.config_tester.run_common_tests()



 def 		UpperCamelCase__	(      self   ):
       snake_case_			= self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_decoder_model_past(*_UpperCAmelCase   )





 def 		UpperCamelCase__	(      self   ):
       return



def 			__lowerCAmelCase       (SCREAMING_SNAKE_CASE = 1000   )->    int:




      """simple docstring"""

      snake_case_			= [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)
      snake_case_			= [0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

      snake_case_			= 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())))