

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 			__UpperCamelCase    (lowerCAmelCase					:  Union[str, Any],    lowerCAmelCase					:  List[Any],    lowerCAmelCase					:  List[str]     )     ->  Union[str, Any]:
      # Construct configuration depending on size
      A    =				{'small': (512, 8, 24), 'medium': (1_024, 8, 36), 'large': (1_536, 16, 48)}
      A ,	A ,	A    =				MODELS[model_size]  # set model hyperparameters
      A    =				ImageGPTConfig(n_embd=__lowerCamelCase,    n_layer=__lowerCamelCase,    n_head=__lowerCamelCase     )
      A    =				ImageGPTForCausalLM(__lowerCamelCase     )

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

      # Save pytorch-model
      A    =				pytorch_dump_folder_path + '/' + WEIGHTS_NAME
      A    =				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    	=			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    	=			parser.parse_args()
   convert_imagegpt_checkpoint_to_pytorch(
       args.imagegpt_checkpoint_path, args.model_size, args.pytorch_dump_folder_path
   )






from math import floor, sqrt


def 			__UpperCamelCase    (lowerCAmelCase					:  int     )     ->  int:
      A    =				0.0
      A    =				1.0
      A    =				int(sqrt(lowerCAmelCase     )     )
      A    =				root
      A    =				0
      while integer_part != 2 * root:
            A    =				denominator * integer_part - numerator
            A    =				(n - numerator**2) / denominator
            A    =				int((root + numerator) / denominator     )
            period += 1
      return period


def 			__UpperCamelCase    (lowerCAmelCase					:  int = 10_000     )     ->  int:
      A    =				0
      for i in range(2,    n + 1     ):
            A    =				sqrt(lowerCAmelCase     )
            if sr - floor(lowerCAmelCase     ) != 0 and continuous_fraction_period(lowerCAmelCase     ) % 2 == 1:
                  count_odd_periods += 1
      return count_odd_periods


if __name__ == "__main__":
  print(F'''{solution(int(input().strip()))}''')



