



import argparse

import torch

from transformers import ImageGPTConfig, ImageGPTForCausalLM, load_tf_weights_in_imagegpt
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()



def  _lowerCAmelCase     (_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase):
					# Construct configuration depending on size
					UpperCamelCase_			= {"small": (5_12, 8, 24), "medium": (10_24, 8, 36), "large": (15_36, 16, 48)}
					UpperCamelCase_	,     UpperCamelCase_	,     UpperCamelCase_			= MODELS[model_size]  # set model hyperparameters
					UpperCamelCase_			= ImageGPTConfig(n_embd=_lowerCAmelCase ,						n_layer=_lowerCAmelCase ,						n_head=_lowerCAmelCase)
					UpperCamelCase_			= ImageGPTForCausalLM(_lowerCAmelCase)

					# Load weights from numpy
					load_tf_weights_in_imagegpt(_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase)

					# Save pytorch-model
					UpperCamelCase_			= pytorch_dump_folder_path + "/" + WEIGHTS_NAME
					UpperCamelCase_			= pytorch_dump_folder_path + "/" + CONFIG_NAME
					print(f"""Save PyTorch model to {pytorch_weights_dump_path}""")
					torch.save(model.state_dict() ,						_lowerCAmelCase)
					print(f"""Save configuration file to {pytorch_config_dump_path}""")
					with open(_lowerCAmelCase ,						"w" ,						encoding="utf-8") as f:
										f.write(config.to_json_string())


if __name__ == "__main__":
	UpperCAmelCase :				Optional[int]							=argparse.ArgumentParser()
	# Required parameters
	parser.add_argument(
	    """--imagegpt_checkpoint_path""",
	    default=None,
	    type=str,
	    required=True,
	    help="""Path to the TensorFlow checkpoint path.""",
	)
	parser.add_argument(
	    """--model_size""",
	    default=None,
	    type=str,
	    required=True,
	    help="""Size of the model (can be either 'small', 'medium' or 'large').""",
	)
	parser.add_argument(
	    """--pytorch_dump_folder_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
	)
	UpperCAmelCase :				List[Any]							=parser.parse_args()
	convert_imagegpt_checkpoint_to_pytorch(
	    args.imagegpt_checkpoint_path, args.model_size, args.pytorch_dump_folder_path
	)

'''simple docstring'''




def _UpperCamelCase (							SCREAMING_SNAKE_CASE_ = 1_000				):
     lowercase_       :							Tuple  					=       [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[Any]  					=       [0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

     lowercase_       :							Optional[Any]  					=       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())))




