
'''simple docstring'''







import argparse

import torch

from transformers import ChineseCLIPConfig, ChineseCLIPModel

def 				_snake_case (		lowercase			,    lowercase			,    lowercase						)       ->       Union[str, Any]:
				__a       :     str								=	pt_weights[F"""{prefix}.in_proj_weight"""].chunk(3			,    dim=0						)
				__a       :     Optional[Any]								=	pt_weights[F"""{prefix}.in_proj_bias"""].chunk(3			,    dim=0						)

				__a       :     Optional[int]								=	pt_weights[F"""{prefix}.out_proj.weight"""]
				__a       :     Union[str, Any]								=	pt_weights[F"""{prefix}.out_proj.bias"""]

				__a       :     Union[str, Any]								=	q_proj
				__a       :     List[str]								=	q_proj_bias

				__a       :     Any								=	k_proj
				__a       :     int								=	k_proj_bias

				__a       :     int								=	v_proj
				__a       :     List[Any]								=	v_proj_bias

				__a       :     str								=	out_proj_weights
				__a       :     str								=	out_proj_bias

def 				_snake_case (		lowercase			,    lowercase			,    lowercase						)       ->       List[str]:
				copy_linear(hf_mlp.fca			,    __UpperCAmelCase			,    F"""{prefix}.c_fc"""						)
				copy_linear(hf_mlp.fca			,    __UpperCAmelCase			,    F"""{prefix}.c_proj"""						)

def 				_snake_case (		lowercase			,    lowercase			,    lowercase						)       ->       Dict:
				__a       :     List[Any]								=	pt_weights[F"""{prefix}.weight"""].data
				__a       :     List[str]								=	pt_weights[F"""{prefix}.bias"""].data

def 				_snake_case (		lowercase			,    lowercase			,    lowercase						)       ->       Dict:
				# copy layer norms
				copy_linear(hf_layer.layer_norma			,    __UpperCAmelCase			,    F"""{prefix}.ln_1"""						)
				copy_linear(hf_layer.layer_norma			,    __UpperCAmelCase			,    F"""{prefix}.ln_2"""						)

				# copy MLP
				copy_mlp(hf_layer.mlp			,    __UpperCAmelCase			,    F"""{prefix}.mlp"""						)

				# copy attn
				copy_attn_layer(hf_layer.self_attn			,    __UpperCAmelCase			,    F"""{prefix}.attn"""						)

def 				_snake_case (		lowercase			,    lowercase			,    lowercase						)       ->       List[str]:
				for layer_id, hf_layer in enumerate(__UpperCAmelCase						):
								copy_layer(__UpperCAmelCase			,    __UpperCAmelCase			,    F"""{prefix}.{layer_id}"""						)

def 				_snake_case (		lowercase			,    lowercase						)       ->       Any:
				# copy projection
				__a       :     List[str]								=	pt_weights["""text_projection"""].data.T

				# copy text encoder
				for name, param in hf_model.text_model.named_parameters():
								__a       :     Any								=	pt_weights[F"""bert.{name}"""].data

def 				_snake_case (		lowercase			,    lowercase						)       ->       Optional[int]:
				# copy projection
				__a       :     Any								=	pt_weights["""visual.proj"""].data.T

				# copy layer norms
				copy_linear(hf_model.vision_model.pre_layrnorm			,    __UpperCAmelCase			,    """visual.ln_pre"""						)
				copy_linear(hf_model.vision_model.post_layernorm			,    __UpperCAmelCase			,    """visual.ln_post"""						)

				# copy embeddings
				__a       :     Optional[Any]								=	pt_weights["""visual.conv1.weight"""].data
				__a       :     List[Any]								=	pt_weights["""visual.class_embedding"""].data
				__a       :     Optional[Any]								=	pt_weights["""visual.positional_embedding"""].data

				# copy encoder
				copy_layers(hf_model.vision_model.encoder.layers			,    __UpperCAmelCase			,    """visual.transformer.resblocks"""						)

@torch.no_grad()
def 				_snake_case (		lowercase			,    lowercase			,    lowercase=None						)       ->       Optional[Any]:
				assert config_path is not None, "Please specify the ChineseCLIP model config of the corresponding model size."
				__a       :     int								=	ChineseCLIPConfig.from_pretrained(__UpperCAmelCase						)

				__a       :     Union[str, Any]								=	ChineseCLIPModel(__UpperCAmelCase						).eval()

				__a       :     Optional[int]								=	torch.load(__UpperCAmelCase			,    map_location="""cpu"""						)["""state_dict"""]
				__a       :     int								=	{(name[7:] if name.startswith("""module."""						) else name): value for name, value in pt_weights.items()}

				copy_text_model_and_projection(__UpperCAmelCase			,    __UpperCAmelCase						)
				copy_vision_model_and_projection(__UpperCAmelCase			,    __UpperCAmelCase						)
				__a       :     int								=	pt_weights["""logit_scale"""].data

				hf_model.save_pretrained(__UpperCAmelCase						)


if __name__ == "__main__":
					__SCREAMING_SNAKE_CASE		:  List[Any]        =      argparse.ArgumentParser()
					parser.add_argument(
					    '--pytorch_dump_folder_path',
					    default=None,
					    type=str,
					    help='Path to the output folder storing converted hf PyTorch model.',
					)
					parser.add_argument(
					    '--checkpoint_path', default=None, type=str, help='Path to original github format ChineseCLIP checkpoint.'
					)
					parser.add_argument(
					    '--config_path', default=None, required=True, type=str, help='Path to hf config.json of model to convert.'
					)
					__SCREAMING_SNAKE_CASE		:  Tuple        =      parser.parse_args()

					convert_chinese_clip_checkpoint(args.checkpoint_path, args.pytorch_dump_folder_path, args.config_path)
					print('The conversion is finished!')




"""simple docstring"""







from math import floor, sqrt


def  __SCREAMING_SNAKE_CASE (  __UpperCAmelCase      ):
		_lowercase				: Optional[int]     =   0.0
		_lowercase				: Dict     =   1.0
		_lowercase				: Optional[int]     =   int(sqrt(__UpperCAmelCase      )      )
		_lowercase				: Optional[Any]     =   root
		_lowercase				: Dict     =   0
		while integer_part != 2 * root:
				_lowercase				: str     =   denominator * integer_part - numerator
				_lowercase				: Optional[int]     =   (n - numerator**2) / denominator
				_lowercase				: List[str]     =   int((root + numerator) / denominator      )
				period += 1
		return period


def  __SCREAMING_SNAKE_CASE (  __UpperCAmelCase = 10000      ):
		_lowercase				: List[str]     =   0
		for i in range(2   ,				n + 1      ):
				_lowercase				: Dict     =   sqrt(__UpperCAmelCase      )
				if sr - floor(__UpperCAmelCase      ) != 0 and continuous_fraction_period(__UpperCAmelCase      ) % 2 == 1:
						count_odd_periods += 1
		return count_odd_periods


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



