



from __future__ import annotations

import copy
import inspect
import json
import math
import os
import tempfile
import unittest
from importlib import import_module

import numpy as np

from transformers import ViTMAEConfig
from transformers.file_utils import cached_property, is_tf_available, is_vision_available
from transformers.testing_utils import require_tf, require_vision, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
		import tensorflow as tf

		from transformers import TFViTMAEForPreTraining, TFViTMAEModel


if is_vision_available():
		from PIL import Image

		from transformers import ViTImageProcessor





class 			__magic_name__ :






		def __init__(    self   :  int					,		UpperCamelCase__   :  Union[str, Any]					,		UpperCamelCase__   :  Optional[Any]=13					,		UpperCamelCase__   :  Union[str, Any]=30					,		UpperCamelCase__   :  Tuple=2					,		UpperCamelCase__   :  Tuple=3					,		UpperCamelCase__   :  Optional[int]=True					,		UpperCamelCase__   :  Any=True					,		UpperCamelCase__   :  Tuple=32					,		UpperCamelCase__   :  Union[str, Any]=2					,		UpperCamelCase__   :  Dict=4					,		UpperCamelCase__   :  List[Any]=37					,		UpperCamelCase__   :  Optional[int]="gelu"					,		UpperCamelCase__   :  Tuple=0.1					,		UpperCamelCase__   :  Union[str, Any]=0.1					,		UpperCamelCase__   :  Union[str, Any]=10					,		UpperCamelCase__   :  Union[str, Any]=0.02					,		UpperCamelCase__   :  Tuple=3					,		UpperCamelCase__   :  Optional[Any]=0.6					,		UpperCamelCase__   :  List[str]=None					,		)					->       str:
								'''simple docstring'''







								UpperCAmelCase								=  parent
								UpperCAmelCase								=  batch_size
								UpperCAmelCase								=  image_size
								UpperCAmelCase								=  patch_size
								UpperCAmelCase								=  num_channels
								UpperCAmelCase								=  is_training
								UpperCAmelCase								=  use_labels
								UpperCAmelCase								=  hidden_size
								UpperCAmelCase								=  num_hidden_layers
								UpperCAmelCase								=  num_attention_heads
								UpperCAmelCase								=  intermediate_size
								UpperCAmelCase								=  hidden_act
								UpperCAmelCase								=  hidden_dropout_prob
								UpperCAmelCase								=  attention_probs_dropout_prob
								UpperCAmelCase								=  type_sequence_label_size
								UpperCAmelCase								=  initializer_range
								UpperCAmelCase								=  mask_ratio
								UpperCAmelCase								=  scope

								# in ViTMAE, the expected sequence length = (num_patches + 1) * (1 - config.mask_ratio), rounded above
								# (we add 1 for the [CLS] token)
								UpperCAmelCase								=  (image_size // patch_size) ** 2
								UpperCAmelCase								=  int(math.ceil((1 - mask_ratio) * (num_patches + 1)   )   )






		def SCREAMING_SNAKE_CASE_      (    self   :  Optional[int]   )					->       Union[str, Any]:
								'''simple docstring'''







								UpperCAmelCase								=  floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]   )

								UpperCAmelCase								=  None
								if self.use_labels:
														UpperCAmelCase								=  ids_tensor([self.batch_size]					,		self.type_sequence_label_size   )

								UpperCAmelCase								=  self.get_config()

								return config, pixel_values, labels






		def SCREAMING_SNAKE_CASE_      (    self   :  int   )					->       int:
								'''simple docstring'''







								return ViTMAEConfig(
								    image_size=self.image_size					,		patch_size=self.patch_size					,		num_channels=self.num_channels					,		hidden_size=self.hidden_size					,		num_hidden_layers=self.num_hidden_layers					,		num_attention_heads=self.num_attention_heads					,		intermediate_size=self.intermediate_size					,		decoder_hidden_size=self.hidden_size					,		decoder_num_hidden_layers=self.num_hidden_layers					,		decoder_num_attention_heads=self.num_attention_heads					,		decoder_intermediate_size=self.intermediate_size					,		hidden_act=self.hidden_act					,		hidden_dropout_prob=self.hidden_dropout_prob					,		attention_probs_dropout_prob=self.attention_probs_dropout_prob					,		is_decoder=SCREAMING_SNAKE_CASE_					,		initializer_range=self.initializer_range					,		mask_ratio=self.mask_ratio					,		)






		def SCREAMING_SNAKE_CASE_      (    self   :  Optional[Any]					,		UpperCamelCase__   :  Optional[Any]					,		UpperCamelCase__   :  List[Any]					,		UpperCamelCase__   :  Optional[int]   )					->       int:
								'''simple docstring'''







								UpperCAmelCase								=  TFViTMAEModel(config=SCREAMING_SNAKE_CASE_   )
								UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_					,		training=SCREAMING_SNAKE_CASE_   )
								self.parent.assertEqual(result.last_hidden_state.shape					,		(self.batch_size, self.seq_length, self.hidden_size)   )






		def SCREAMING_SNAKE_CASE_      (    self   :  Any					,		UpperCamelCase__   :  Tuple					,		UpperCamelCase__   :  List[str]					,		UpperCamelCase__   :  List[str]   )					->       int:
								'''simple docstring'''







								UpperCAmelCase								=  TFViTMAEForPreTraining(SCREAMING_SNAKE_CASE_   )
								UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_					,		training=SCREAMING_SNAKE_CASE_   )
								# expected sequence length = num_patches
								UpperCAmelCase								=  (self.image_size // self.patch_size) ** 2
								UpperCAmelCase								=  self.patch_size**2 * self.num_channels
								self.parent.assertEqual(result.logits.shape					,		(self.batch_size, num_patches, expected_num_channels)   )

								# test greyscale images
								UpperCAmelCase								=  1
								UpperCAmelCase								=  TFViTMAEForPreTraining(SCREAMING_SNAKE_CASE_   )

								UpperCAmelCase								=  floats_tensor([self.batch_size, 1, self.image_size, self.image_size]   )
								UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_					,		training=SCREAMING_SNAKE_CASE_   )
								UpperCAmelCase								=  self.patch_size**2
								self.parent.assertEqual(result.logits.shape					,		(self.batch_size, num_patches, expected_num_channels)   )







		def SCREAMING_SNAKE_CASE_      (    self   :  Union[str, Any]   )					->       str:
								'''simple docstring'''







								UpperCAmelCase								=  self.prepare_config_and_inputs()
								(UpperCAmelCase)								=  config_and_inputs
								UpperCAmelCase								=  {"""pixel_values""": pixel_values}
								return config, inputs_dict





@require_tf
class 			__magic_name__ (				_lowerCAmelCase,	_lowerCAmelCase,	unittest.TestCase    ):
		lowercase   :							Any        =(TFViTMAEModel, TFViTMAEForPreTraining) if is_tf_available() else ()
		lowercase   :							List[str]        ={'''feature-extraction''': TFViTMAEModel} if is_tf_available() else {}

		lowercase   :							Optional[int]        =False
		lowercase   :							Any        =False
		lowercase   :							List[Any]        =False
		lowercase   :							Optional[Any]        =False






		def SCREAMING_SNAKE_CASE_      (    self   :  Any   )					->       int:
								'''simple docstring'''







								UpperCAmelCase								=  TFViTMAEModelTester(self   )
								UpperCAmelCase								=  ConfigTester(self					,		config_class=SCREAMING_SNAKE_CASE_					,		has_text_modality=SCREAMING_SNAKE_CASE_					,		hidden_size=37   )






		def SCREAMING_SNAKE_CASE_      (    self   :  Dict   )					->       Any:
								'''simple docstring'''







								self.config_tester.run_common_tests()






		@unittest.skip(reason="ViTMAE does not use inputs_embeds"   )
		def SCREAMING_SNAKE_CASE_      (    self   :  List[Any]   )					->       str:
								'''simple docstring'''







								pass






		def SCREAMING_SNAKE_CASE_      (    self   :  Union[str, Any]   )					->       Optional[int]:
								'''simple docstring'''







								UpperCAmelCase								=  self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
														UpperCAmelCase								=  model_class(SCREAMING_SNAKE_CASE_   )
														self.assertIsInstance(model.get_input_embeddings()					,		(tf.keras.layers.Layer)   )
														UpperCAmelCase								=  model.get_output_embeddings()
														self.assertTrue(x is None or isinstance(SCREAMING_SNAKE_CASE_					,		tf.keras.layers.Layer   )   )






		def SCREAMING_SNAKE_CASE_      (    self   :  Optional[Any]   )					->       Any:
								'''simple docstring'''







								UpperCAmelCase								=  self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
														UpperCAmelCase								=  model_class(SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  inspect.signature(model.call   )
														# signature.parameters is an OrderedDict => so arg_names order is deterministic
														UpperCAmelCase								=  [*signature.parameters.keys()]

														UpperCAmelCase								=  ["""pixel_values"""]
														self.assertListEqual(arg_names[:1]					,		SCREAMING_SNAKE_CASE_   )






		def SCREAMING_SNAKE_CASE_      (    self   :  List[Any]   )					->       str:
								'''simple docstring'''







								UpperCAmelCase								=  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_   )






		def SCREAMING_SNAKE_CASE_      (    self   :  Tuple   )					->       Tuple:
								'''simple docstring'''







								UpperCAmelCase								=  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_pretraining(*SCREAMING_SNAKE_CASE_   )






		def SCREAMING_SNAKE_CASE_      (    self   :  Any   )					->       str:
								'''simple docstring'''







								np.random.seed(2   )

								UpperCAmelCase								=  self.model_tester.prepare_config_and_inputs_for_common()

								UpperCAmelCase								=  int((config.image_size // config.patch_size) ** 2   )
								UpperCAmelCase								=  np.random.uniform(size=(self.model_tester.batch_size, num_patches)   )

								for model_class in self.all_model_classes:
														UpperCAmelCase								=  model_class(SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  self._prepare_for_class(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )

														UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_					,		noise=SCREAMING_SNAKE_CASE_   )

														UpperCAmelCase								=  copy.deepcopy(self._prepare_for_class(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )   )
														UpperCAmelCase								=  model(**SCREAMING_SNAKE_CASE_					,		noise=SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  outputs_dict[0].numpy()
														UpperCAmelCase								=  outputs_keywords[0].numpy()

														self.assertLess(np.sum(np.abs(output_dict - output_keywords   )   )					,		1e-6   )






		def SCREAMING_SNAKE_CASE_      (    self   :  Tuple   )					->       Any:
								'''simple docstring'''







								np.random.seed(2   )

								UpperCAmelCase								=  self.model_tester.prepare_config_and_inputs_for_common()

								UpperCAmelCase								=  int((config.image_size // config.patch_size) ** 2   )
								UpperCAmelCase								=  np.random.uniform(size=(self.model_tester.batch_size, num_patches)   )

								def prepare_numpy_arrays(UpperCamelCase__   :  Optional[int]   ):
														UpperCAmelCase								=  {}
														for k, v in inputs_dict.items():
																				if tf.is_tensor(SCREAMING_SNAKE_CASE_   ):
																										UpperCAmelCase								=  v.numpy()
																				else:
																										UpperCAmelCase								=  np.array(SCREAMING_SNAKE_CASE_   )

														return inputs_np_dict

								for model_class in self.all_model_classes:
														UpperCAmelCase								=  model_class(SCREAMING_SNAKE_CASE_   )

														UpperCAmelCase								=  self._prepare_for_class(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  prepare_numpy_arrays(SCREAMING_SNAKE_CASE_   )

														UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_					,		noise=SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  model(**SCREAMING_SNAKE_CASE_					,		noise=SCREAMING_SNAKE_CASE_   )
														self.assert_outputs_same(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )






		def SCREAMING_SNAKE_CASE_      (    self   :  List[Any]					,		UpperCamelCase__   :  Tuple					,		UpperCamelCase__   :  Any					,		UpperCamelCase__   :  Dict   )					->       Dict:
								'''simple docstring'''







								np.random.seed(2   )

								UpperCAmelCase								=  int((tf_model.config.image_size // tf_model.config.patch_size) ** 2   )
								UpperCAmelCase								=  np.random.uniform(size=(self.model_tester.batch_size, num_patches)   )
								UpperCAmelCase								=  tf.constant(SCREAMING_SNAKE_CASE_   )

								# Add `noise` argument.
								# PT inputs will be prepared in `super().check_pt_tf_models()` with this added `noise` argument
								UpperCAmelCase								=  tf_noise

								super().check_pt_tf_models(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )






		def SCREAMING_SNAKE_CASE_      (    self   :  List[str]   )					->       int:
								'''simple docstring'''







								np.random.seed(2   )

								UpperCAmelCase								=  self.model_tester.prepare_config_and_inputs_for_common()

								UpperCAmelCase								=  {
								    module_member
								    for model_class in self.all_model_classes
								    for module in (import_module(model_class.__module__   ),)
								    for module_member_name in dir(SCREAMING_SNAKE_CASE_   )
								    if module_member_name.endswith("MainLayer"   )
								    # This condition is required, since `modeling_tf_clip.py` has 3 classes whose names end with `MainLayer`.
								    and module_member_name[: -len("MainLayer"   )] == model_class.__name__[: -len("Model"   )]
								    for module_member in (getattr(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   ),)
								    if isinstance(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )
								    and tf.keras.layers.Layer in module_member.__bases__
								    and getattr(SCREAMING_SNAKE_CASE_					,		"_keras_serializable"					,		SCREAMING_SNAKE_CASE_   )
								}

								UpperCAmelCase								=  int((config.image_size // config.patch_size) ** 2   )
								UpperCAmelCase								=  np.random.uniform(size=(self.model_tester.batch_size, num_patches)   )
								UpperCAmelCase								=  tf.convert_to_tensor(SCREAMING_SNAKE_CASE_   )
								inputs_dict.update({"noise": noise}   )

								for main_layer_class in tf_main_layer_classes:
														UpperCAmelCase								=  main_layer_class(SCREAMING_SNAKE_CASE_   )

														UpperCAmelCase								=  {
														    name: tf.keras.Input(tensor.shape[1:]					,		dtype=tensor.dtype   ) for name, tensor in inputs_dict.items()
														}

														UpperCAmelCase								=  tf.keras.Model(SCREAMING_SNAKE_CASE_					,		outputs=main_layer(SCREAMING_SNAKE_CASE_   )   )
														UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_   )

														with tempfile.TemporaryDirectory() as tmpdirname:
																				UpperCAmelCase								=  os.path.join(SCREAMING_SNAKE_CASE_					,		"keras_model.h5"   )
																				model.save(SCREAMING_SNAKE_CASE_   )
																				UpperCAmelCase								=  tf.keras.models.load_model(
																				    SCREAMING_SNAKE_CASE_					,		custom_objects={main_layer_class.__name__: main_layer_class}   )
																				assert isinstance(SCREAMING_SNAKE_CASE_					,		tf.keras.Model   )
																				UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_   )
																				self.assert_outputs_same(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )






		@slow
		def SCREAMING_SNAKE_CASE_      (    self   :  List[Any]   )					->       List[str]:
								'''simple docstring'''







								np.random.seed(2   )

								UpperCAmelCase								=  self.model_tester.prepare_config_and_inputs_for_common()

								UpperCAmelCase								=  int((config.image_size // config.patch_size) ** 2   )
								UpperCAmelCase								=  np.random.uniform(size=(self.model_tester.batch_size, num_patches)   )

								for model_class in self.all_model_classes:
														UpperCAmelCase								=  model_class(SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  self._prepare_for_class(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_					,		noise=SCREAMING_SNAKE_CASE_   )

														if model_class.__name__ == "TFViTMAEModel":
																				UpperCAmelCase								=  outputs.last_hidden_state.numpy()
																				UpperCAmelCase								=  0
														else:
																				UpperCAmelCase								=  outputs.logits.numpy()
																				UpperCAmelCase								=  0

														with tempfile.TemporaryDirectory() as tmpdirname:
																				model.save_pretrained(SCREAMING_SNAKE_CASE_					,		saved_model=SCREAMING_SNAKE_CASE_   )
																				UpperCAmelCase								=  model_class.from_pretrained(SCREAMING_SNAKE_CASE_   )
																				UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_					,		noise=SCREAMING_SNAKE_CASE_   )

																				if model_class.__name__ == "TFViTMAEModel":
																										UpperCAmelCase								=  after_outputs["""last_hidden_state"""].numpy()
																										UpperCAmelCase								=  0
																				else:
																										UpperCAmelCase								=  after_outputs["""logits"""].numpy()
																										UpperCAmelCase								=  0

																				UpperCAmelCase								=  np.amax(np.abs(out_a - out_a   )   )
																				self.assertLessEqual(SCREAMING_SNAKE_CASE_					,		1e-5   )






		def SCREAMING_SNAKE_CASE_      (    self   :  Optional[int]   )					->       str:
								'''simple docstring'''







								np.random.seed(2   )

								UpperCAmelCase								=  self.model_tester.prepare_config_and_inputs_for_common()

								UpperCAmelCase								=  int((config.image_size // config.patch_size) ** 2   )
								UpperCAmelCase								=  np.random.uniform(size=(self.model_tester.batch_size, num_patches)   )

								for model_class in self.all_model_classes:
														UpperCAmelCase								=  model_class(SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  self._prepare_for_class(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )

														UpperCAmelCase								=  model(SCREAMING_SNAKE_CASE_					,		noise=SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  model.get_config()
														# make sure that returned config is jsonifiable, which is required by keras
														json.dumps(SCREAMING_SNAKE_CASE_   )
														UpperCAmelCase								=  model_class.from_config(model.get_config()   )
														# make sure it also accepts a normal config
														UpperCAmelCase								=  model_class.from_config(model.config   )
														UpperCAmelCase								=  new_model(SCREAMING_SNAKE_CASE_   )  # Build model
														new_model.set_weights(model.get_weights()   )
														UpperCAmelCase								=  new_model(SCREAMING_SNAKE_CASE_					,		noise=SCREAMING_SNAKE_CASE_   )

														self.assert_outputs_same(SCREAMING_SNAKE_CASE_					,		SCREAMING_SNAKE_CASE_   )






		@unittest.skip(
		    reason="ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load\n    to get deterministic results."   )
		def SCREAMING_SNAKE_CASE_      (    self   :  Any   )					->       int:
								'''simple docstring'''







								pass






		@unittest.skip(reason="ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load"   )
		def SCREAMING_SNAKE_CASE_      (    self   :  Optional[int]   )					->       Dict:
								'''simple docstring'''







								pass







		@slow
		def SCREAMING_SNAKE_CASE_      (    self   :  Union[str, Any]   )					->       List[Any]:
								'''simple docstring'''







								UpperCAmelCase								=  TFViTMAEModel.from_pretrained("google/vit-base-patch16-224"   )
								self.assertIsNotNone(SCREAMING_SNAKE_CASE_   )

def  lowerCamelCase_()			->							Optional[int]:
						UpperCAmelCase								=  Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"     )
						return image





@require_tf
@require_vision
class 			__magic_name__ (				unittest.TestCase    ):






		@cached_property
		def SCREAMING_SNAKE_CASE_      (    self   :  List[Any]   )					->       Optional[int]:
								'''simple docstring'''







								return ViTImageProcessor.from_pretrained("facebook/vit-mae-base"   ) if is_vision_available() else None







		@slow
		def SCREAMING_SNAKE_CASE_      (    self   :  List[Any]   )					->       Tuple:
								'''simple docstring'''







								np.random.seed(2   )

								UpperCAmelCase								=  TFViTMAEForPreTraining.from_pretrained("facebook/vit-mae-base"   )

								UpperCAmelCase								=  self.default_image_processor
								UpperCAmelCase								=  prepare_img()
								UpperCAmelCase								=  image_processor(images=SCREAMING_SNAKE_CASE_					,		return_tensors="tf"   )

								# prepare a noise vector that will be also used for testing the TF model
								# (this way we can ensure that the PT and TF models operate on the same inputs)
								UpperCAmelCase								=  ViTMAEConfig()
								UpperCAmelCase								=  int((vit_mae_config.image_size // vit_mae_config.patch_size) ** 2   )
								UpperCAmelCase								=  np.random.uniform(size=(1, num_patches)   )

								# forward pass
								UpperCAmelCase								=  model(**SCREAMING_SNAKE_CASE_					,		noise=SCREAMING_SNAKE_CASE_   )

								# verify the logits
								UpperCAmelCase								=  tf.convert_to_tensor([1, 1_96, 7_68]   )
								self.assertEqual(outputs.logits.shape					,		SCREAMING_SNAKE_CASE_   )

								UpperCAmelCase								=  tf.convert_to_tensor(
								    [[-0.05_48, -1.70_23, -0.93_25], [0.37_21, -0.56_70, -0.22_33], [0.82_35, -1.38_78, -0.35_24]]   )

								tf.debugging.assert_near(outputs.logits[0, :3, :3]					,		SCREAMING_SNAKE_CASE_					,		atol=1e-4   )








def  lowerCAmelCase_	(lowerCAmelCase__:		int  ):





			"""simple docstring"""


			if n == 1 or not isinstance(lowerCAmelCase__		,						lowerCAmelCase__  ):
						return 0
			elif n == 2:
						return 1
			else:
						UpperCAmelCase_:		Optional[int]							      =     [0, 1]
						for i in range(2		,						n + 1  ):
									sequence.append(sequence[i - 1] + sequence[i - 2]  )

						return sequence[n]







def  lowerCAmelCase_	(lowerCAmelCase__:		int  ):





			"""simple docstring"""


			UpperCAmelCase_:		str							      =     0
			UpperCAmelCase_:		str							      =     2

			while digits < n:
						index += 1
						UpperCAmelCase_:		Union[str, Any]							      =     len(str(fibonacci(lowerCAmelCase__  )  )  )

			return index







def  lowerCAmelCase_	(lowerCAmelCase__:		int = 1_0_0_0  ):





			"""simple docstring"""


			return fibonacci_digits_index(lowerCAmelCase__  )


if __name__ == "__main__":
	print(solution(int(str(input()).strip())))






