


import os
from typing import List, Union

import tensorflow as tf
from tensorflow_text import BertTokenizer as BertTokenizerLayer
from tensorflow_text import FastBertTokenizer, ShrinkLongestTrimmer, case_fold_utfa, combine_segments, pad_model_inputs

from .tokenization_bert import BertTokenizer







class lowerCAmelCase_		(					tf.keras.layers.Layer			):

 '''simple docstring'''

 def __init__(      self						, _UpperCAmelCase						, _UpperCAmelCase						, _UpperCAmelCase = None						, _UpperCAmelCase = None						, _UpperCAmelCase = None						, _UpperCAmelCase = "longest"						, _UpperCAmelCase = True						, _UpperCAmelCase = 5_12						, _UpperCAmelCase = None						, _UpperCAmelCase = True						, _UpperCAmelCase = True						, _UpperCAmelCase = True						, **_UpperCAmelCase						, ):
       super().__init__()
       if use_fast_bert_tokenizer:
             snake_case_			= FastBertTokenizer(
                 _UpperCAmelCase						, token_out_type=tf.intaa						, lower_case_nfd_strip_accents=_UpperCAmelCase						, **_UpperCAmelCase   )
       else:
             snake_case_			= tf.lookup.StaticVocabularyTable(
                 tf.lookup.KeyValueTensorInitializer(
                     keys=_UpperCAmelCase						, key_dtype=tf.string						, values=tf.range(tf.size(_UpperCAmelCase						, out_type=tf.intaa   )						, dtype=tf.intaa   )						, value_dtype=tf.intaa						, )						, num_oov_buckets=1						, )
             snake_case_			= BertTokenizerLayer(
                 _UpperCAmelCase						, token_out_type=tf.intaa						, lower_case=_UpperCAmelCase						, **_UpperCAmelCase   )

       snake_case_			= vocab_list
       snake_case_			= do_lower_case
       snake_case_			= cls_token_id or vocab_list.index('''[CLS]'''   )
       snake_case_			= sep_token_id or vocab_list.index('''[SEP]'''   )
       snake_case_			= pad_token_id or vocab_list.index('''[PAD]'''   )
       snake_case_			= ShrinkLongestTrimmer(max_length - 3						, axis=1   )  # Allow room for special tokens
       snake_case_			= max_length
       snake_case_			= padding
       snake_case_			= truncation
       snake_case_			= pad_to_multiple_of
       snake_case_			= return_token_type_ids
       snake_case_			= return_attention_mask



 @classmethod
 def 		UpperCamelCase__	(      cls						, _UpperCAmelCase						, **_UpperCAmelCase   ):  # noqa: F821
       snake_case_			= kwargs.pop('''do_lower_case'''						, _UpperCAmelCase   )
       snake_case_			= tokenizer.do_lower_case if do_lower_case is None else do_lower_case
       snake_case_			= kwargs.pop('''cls_token_id'''						, _UpperCAmelCase   )
       snake_case_			= tokenizer.cls_token_id if cls_token_id is None else cls_token_id
       snake_case_			= kwargs.pop('''sep_token_id'''						, _UpperCAmelCase   )
       snake_case_			= tokenizer.sep_token_id if sep_token_id is None else sep_token_id
       snake_case_			= kwargs.pop('''pad_token_id'''						, _UpperCAmelCase   )
       snake_case_			= tokenizer.pad_token_id if pad_token_id is None else pad_token_id

       snake_case_			= tokenizer.get_vocab()
       snake_case_			= sorted([(wordpiece, idx) for wordpiece, idx in vocab.items()]						, key=lambda _UpperCAmelCase   : x[1]   )
       snake_case_			= [entry[0] for entry in vocab]
       return cls(
           vocab_list=_UpperCAmelCase						, do_lower_case=_UpperCAmelCase						, cls_token_id=_UpperCAmelCase						, sep_token_id=_UpperCAmelCase						, pad_token_id=_UpperCAmelCase						, **_UpperCAmelCase						, )



 @classmethod
 def 		UpperCamelCase__	(      cls						, _UpperCAmelCase						, *_UpperCAmelCase						, **_UpperCAmelCase   ):
       try:
             snake_case_			= BertTokenizer.from_pretrained(_UpperCAmelCase						, *_UpperCAmelCase						, **_UpperCAmelCase   )
       except:  # noqa: E722
             from .tokenization_bert_fast import BertTokenizerFast

             snake_case_			= BertTokenizerFast.from_pretrained(_UpperCAmelCase						, *_UpperCAmelCase						, **_UpperCAmelCase   )
       return cls.from_tokenizer(_UpperCAmelCase						, **_UpperCAmelCase   )



 def 		UpperCamelCase__	(      self						, _UpperCAmelCase   ):
       if self.do_lower_case:
             snake_case_			= case_fold_utfa(_UpperCAmelCase   )
       snake_case_			= self.tf_tokenizer.tokenize(_UpperCAmelCase   )
       return tokens.merge_dims(1						, -1   )



 def 		UpperCamelCase__	(      self						, _UpperCAmelCase						, _UpperCAmelCase=None						, _UpperCAmelCase=None						, _UpperCAmelCase=None						, _UpperCAmelCase=None						, _UpperCAmelCase=None						, _UpperCAmelCase=None						, _UpperCAmelCase=None						, ):
       if padding is None:
             snake_case_			= self.padding
       if padding not in ("longest", "max_length"):
             raise ValueError('''Padding must be either \'longest\' or \'max_length\'!'''   )
       if max_length is not None and text_pair is not None:
             # Because we have to instantiate a Trimmer to do it properly
             raise ValueError('''max_length cannot be overridden at call time when truncating paired texts!'''   )
       if max_length is None:
             snake_case_			= self.max_length
       if truncation is None:
             snake_case_			= self.truncation
       if pad_to_multiple_of is None:
             snake_case_			= self.pad_to_multiple_of
       if return_token_type_ids is None:
             snake_case_			= self.return_token_type_ids
       if return_attention_mask is None:
             snake_case_			= self.return_attention_mask
       if not isinstance(_UpperCAmelCase						, tf.Tensor   ):
             snake_case_			= tf.convert_to_tensor(_UpperCAmelCase   )
       if text_pair is not None and not isinstance(_UpperCAmelCase						, tf.Tensor   ):
             snake_case_			= tf.convert_to_tensor(_UpperCAmelCase   )
       if text_pair is not None:
             if text.shape.rank > 1:
                   raise ValueError('''text argument should not be multidimensional when a text pair is supplied!'''   )
             if text_pair.shape.rank > 1:
                   raise ValueError('''text_pair should not be multidimensional!'''   )
       if text.shape.rank == 2:
             snake_case_			,       snake_case_			= text[:, 0], text[:, 1]
       snake_case_			= self.unpaired_tokenize(_UpperCAmelCase   )
       if text_pair is None:  # Unpaired text
             if truncation:
                   snake_case_			= text[:, : max_length - 2]  # Allow room for special tokens
             snake_case_			,       snake_case_			= combine_segments(
                 (text,)						, start_of_sequence_id=self.cls_token_id						, end_of_segment_id=self.sep_token_id   )
       else:  # Paired text
             snake_case_			= self.unpaired_tokenize(_UpperCAmelCase   )
             if truncation:
                   snake_case_			,       snake_case_			= self.paired_trimmer.trim([text, text_pair]   )
             snake_case_			,       snake_case_			= combine_segments(
                 (text, text_pair)						, start_of_sequence_id=self.cls_token_id						, end_of_segment_id=self.sep_token_id   )
       if padding == "longest":
             snake_case_			= input_ids.bounding_shape(axis=1   )
             if pad_to_multiple_of is not None:
                   # No ceiling division in tensorflow, so we negate floordiv instead
                   snake_case_			= pad_to_multiple_of * (-tf.math.floordiv(-pad_length						, _UpperCAmelCase   ))
       else:
             snake_case_			= max_length

       snake_case_			,       snake_case_			= pad_model_inputs(_UpperCAmelCase						, max_seq_length=_UpperCAmelCase						, pad_value=self.pad_token_id   )
       snake_case_			= {'''input_ids''': input_ids}
       if return_attention_mask:
             snake_case_			= attention_mask
       if return_token_type_ids:
             snake_case_			,       snake_case_			= pad_model_inputs(
                 _UpperCAmelCase						, max_seq_length=_UpperCAmelCase						, pad_value=self.pad_token_id   )
             snake_case_			= token_type_ids
       return output





 def 		UpperCamelCase__	(      self   ):
       return {
           "vocab_list": self.vocab_list,
           "do_lower_case": self.do_lower_case,
           "cls_token_id": self.cls_token_id,
           "sep_token_id": self.sep_token_id,
           "pad_token_id": self.pad_token_id,
       }



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