




import inspect
import unittest

from datasets import load_dataset
from packaging import version

from transformers import BeitConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
   import torch
   from torch import nn

   from transformers import (
       MODEL_MAPPING,
       BeitForImageClassification,
       BeitForMaskedImageModeling,
       BeitForSemanticSegmentation,
       BeitModel,
   )
   from transformers.models.beit.modeling_beit import BEIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
   import PIL
   from PIL import Image

   from transformers import BeitImageProcessor
class 			SCREAMING_SNAKE_CASE__  :
      def __init__(	self    :	List[str]					,							SCREAMING_SNAKE_CASE__    :	Any					,							SCREAMING_SNAKE_CASE__    :	str=1_0_0					,							SCREAMING_SNAKE_CASE__    :	str=1_3					,							SCREAMING_SNAKE_CASE__    :	str=3_0					,							SCREAMING_SNAKE_CASE__    :	Optional[int]=2					,							SCREAMING_SNAKE_CASE__    :	List[str]=3					,							SCREAMING_SNAKE_CASE__    :	int=True					,							SCREAMING_SNAKE_CASE__    :	int=True					,							SCREAMING_SNAKE_CASE__    :	Tuple=3_2					,							SCREAMING_SNAKE_CASE__    :	Union[str, Any]=4					,							SCREAMING_SNAKE_CASE__    :	Optional[Any]=4					,							SCREAMING_SNAKE_CASE__    :	Dict=3_7					,							SCREAMING_SNAKE_CASE__    :	List[Any]="gelu"					,							SCREAMING_SNAKE_CASE__    :	Union[str, Any]=0.1					,							SCREAMING_SNAKE_CASE__    :	Optional[int]=0.1					,							SCREAMING_SNAKE_CASE__    :	str=1_0					,							SCREAMING_SNAKE_CASE__    :	List[Any]=0.02					,							SCREAMING_SNAKE_CASE__    :	int=3					,							SCREAMING_SNAKE_CASE__    :	Optional[Any]=None					,							SCREAMING_SNAKE_CASE__    :	Optional[Any]=[0, 1, 2, 3]					,							)		->      str:
             a_ :		Tuple							=  parent
             a_ :		List[Any]							=  1_0_0
             a_ :		str							=  batch_size
             a_ :		List[str]							=  image_size
             a_ :		List[Any]							=  patch_size
             a_ :		Tuple							=  num_channels
             a_ :		int							=  is_training
             a_ :		Any							=  use_labels
             a_ :		str							=  hidden_size
             a_ :		Any							=  num_hidden_layers
             a_ :		Optional[int]							=  num_attention_heads
             a_ :		List[Any]							=  intermediate_size
             a_ :		Union[str, Any]							=  hidden_act
             a_ :		Optional[Any]							=  hidden_dropout_prob
             a_ :		Tuple							=  attention_probs_dropout_prob
             a_ :		Any							=  type_sequence_label_size
             a_ :		Dict							=  initializer_range
             a_ :		Union[str, Any]							=  scope
             a_ :		str							=  out_indices
             a_ :		int							=  num_labels

             # in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
             a_ :		List[Any]							=  (image_size // patch_size) ** 2
             a_ :		List[Any]							=  num_patches + 1
      def 	SCREAMING_SNAKE_CASE							(	self    :	List[str]					)		->      Dict:
             a_ :		str							=  floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)

             a_ :		int							=  None
             a_ :		Optional[Any]							=  None
             if self.use_labels:
                    a_ :		Tuple							=  ids_tensor([self.batch_size]					,							self.type_sequence_label_size					)
                    a_ :		Tuple							=  ids_tensor([self.batch_size, self.image_size, self.image_size]					,							self.num_labels					)

             a_ :		Any							=  self.get_config()

             return config, pixel_values, labels, pixel_labels
      def 	SCREAMING_SNAKE_CASE							(	self    :	Any					)		->      Optional[Any]:
             return BeitConfig(
                 vocab_size=self.vocab_size					,							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					,							hidden_act=self.hidden_act					,							hidden_dropout_prob=self.hidden_dropout_prob					,							attention_probs_dropout_prob=self.attention_probs_dropout_prob					,							is_decoder=__snake_case					,							initializer_range=self.initializer_range					,							out_indices=self.out_indices					,							)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Dict					,							SCREAMING_SNAKE_CASE__    :	int					,							SCREAMING_SNAKE_CASE__    :	Optional[int]					,							SCREAMING_SNAKE_CASE__    :	Any					,							SCREAMING_SNAKE_CASE__    :	List[str]					)		->      Tuple:
             a_ :		str							=  BeitModel(config=__snake_case					)
             model.to(__snake_case					)
             model.eval()
             a_ :		Union[str, Any]							=  model(__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					,							SCREAMING_SNAKE_CASE__    :	Any					,							SCREAMING_SNAKE_CASE__    :	str					,							SCREAMING_SNAKE_CASE__    :	int					,							SCREAMING_SNAKE_CASE__    :	Any					)		->      Optional[Any]:
             a_ :		List[str]							=  BeitForMaskedImageModeling(config=__snake_case					)
             model.to(__snake_case					)
             model.eval()
             a_ :		Tuple							=  model(__snake_case					)
             self.parent.assertEqual(result.logits.shape					,							(self.batch_size, self.seq_length - 1, self.vocab_size)					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	str					,							SCREAMING_SNAKE_CASE__    :	str					,							SCREAMING_SNAKE_CASE__    :	List[Any]					,							SCREAMING_SNAKE_CASE__    :	List[str]					,							SCREAMING_SNAKE_CASE__    :	Tuple					)		->      Any:
             a_ :		List[str]							=  self.type_sequence_label_size
             a_ :		List[str]							=  BeitForImageClassification(__snake_case					)
             model.to(__snake_case					)
             model.eval()
             a_ :		str							=  model(__snake_case					,							labels=__snake_case					)
             self.parent.assertEqual(result.logits.shape					,							(self.batch_size, self.type_sequence_label_size)					)

             # test greyscale images
             a_ :		Tuple							=  1
             a_ :		int							=  BeitForImageClassification(__snake_case					)
             model.to(__snake_case					)
             model.eval()

             a_ :		Tuple							=  floats_tensor([self.batch_size, 1, self.image_size, self.image_size]					)
             a_ :		Optional[Any]							=  model(__snake_case					,							labels=__snake_case					)
             self.parent.assertEqual(result.logits.shape					,							(self.batch_size, self.type_sequence_label_size)					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Dict					,							SCREAMING_SNAKE_CASE__    :	Union[str, Any]					,							SCREAMING_SNAKE_CASE__    :	Union[str, Any]					,							SCREAMING_SNAKE_CASE__    :	Dict					,							SCREAMING_SNAKE_CASE__    :	Tuple					)		->      Union[str, Any]:
             a_ :		Dict							=  self.num_labels
             a_ :		Dict							=  BeitForSemanticSegmentation(__snake_case					)
             model.to(__snake_case					)
             model.eval()
             a_ :		Dict							=  model(__snake_case					)
             self.parent.assertEqual(
                 result.logits.shape					,							(self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)					)
             a_ :		str							=  model(__snake_case					,							labels=__snake_case					)
             self.parent.assertEqual(
                 result.logits.shape					,							(self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)					)

      def 	SCREAMING_SNAKE_CASE							(	self    :	str					)		->      Optional[Any]:
             a_ :		List[Any]							=  self.prepare_config_and_inputs()
             a_							,		a_							,		a_							,		a_ :		Union[str, Any]							=  config_and_inputs
             a_ :		Tuple							=  {'pixel_values': pixel_values}
             return config, inputs_dict
@require_torch
class 			SCREAMING_SNAKE_CASE__  (    A__						,   A__						,   unittest.TestCase      ):
      snake_case__    :					Tuple					       =						(
          (BeitModel, BeitForImageClassification, BeitForMaskedImageModeling, BeitForSemanticSegmentation)
          if is_torch_available()
          else ()
      )
      snake_case__    :					Optional[int]					       =						(
          {
              '''feature-extraction''': BeitModel,
              '''image-classification''': BeitForImageClassification,
              '''image-segmentation''': BeitForSemanticSegmentation,
          }
          if is_torch_available()
          else {}
      )

      snake_case__    :					int					       =						False
      snake_case__    :					Tuple					       =						False
      snake_case__    :					Optional[Any]					       =						False
      def 	SCREAMING_SNAKE_CASE							(	self    :	int					)		->      str:
             a_ :		Optional[int]							=  BeitModelTester(self					)
             a_ :		Optional[int]							=  ConfigTester(self					,							config_class=__snake_case					,							has_text_modality=__snake_case					,							hidden_size=3_7					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Optional[Any]					)		->      int:
             self.config_tester.run_common_tests()
      @unittest.skip(reason='BEiT does not use inputs_embeds'					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	str					)		->      List[str]:
             pass
      @require_torch_multi_gpu
      @unittest.skip(reason='BEiT has some layers using `add_module` which doesn\'t work well with `nn.DataParallel`'					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Tuple					)		->      int:
             pass
      def 	SCREAMING_SNAKE_CASE							(	self    :	Tuple					)		->      Any:
             a_							,		a_ :		Union[str, Any]							=  self.model_tester.prepare_config_and_inputs_for_common()

             for model_class in self.all_model_classes:
                    a_ :		Union[str, Any]							=  model_class(__snake_case					)
                    self.assertIsInstance(model.get_input_embeddings()					,							(nn.Module)					)
                    a_ :		str							=  model.get_output_embeddings()
                    self.assertTrue(x is None or isinstance(__snake_case					,							nn.Linear					)					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Any					)		->      Union[str, Any]:
             a_							,		a_ :		Optional[Any]							=  self.model_tester.prepare_config_and_inputs_for_common()

             for model_class in self.all_model_classes:
                    a_ :		Dict							=  model_class(__snake_case					)
                    a_ :		List[str]							=  inspect.signature(model.forward					)
                    # signature.parameters is an OrderedDict => so arg_names order is deterministic
                    a_ :		Dict							=  [*signature.parameters.keys()]

                    a_ :		List[Any]							=  ['pixel_values']
                    self.assertListEqual(arg_names[:1]					,							__snake_case					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	List[str]					)		->      Union[str, Any]:
             a_ :		Optional[Any]							=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_model(*__snake_case					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	List[Any]					)		->      int:
             a_ :		Any							=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_masked_lm(*__snake_case					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Any					)		->      Dict:
             a_ :		Dict							=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_image_classification(*__snake_case					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Dict					)		->      List[str]:
             a_ :		List[Any]							=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_semantic_segmentation(*__snake_case					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	str					)		->      int:
             if not self.model_tester.is_training:
                    return

             a_							,		a_ :		Union[str, Any]							=  self.model_tester.prepare_config_and_inputs_for_common()
             a_ :		Dict							=  True

             for model_class in self.all_model_classes:
                    # we don't test BeitForMaskedImageModeling
                    if model_class in [*get_values(__snake_case					), BeitForMaskedImageModeling]:
                           continue

                    a_ :		Union[str, Any]							=  model_class(__snake_case					)
                    model.to(__snake_case					)
                    model.train()
                    a_ :		Optional[Any]							=  self._prepare_for_class(__snake_case					,							__snake_case					,							return_labels=__snake_case					)
                    a_ :		Optional[Any]							=  model(**__snake_case					).loss
                    loss.backward()
      def 	SCREAMING_SNAKE_CASE							(	self    :	Tuple					)		->      List[str]:
             a_							,		a_ :		List[Any]							=  self.model_tester.prepare_config_and_inputs_for_common()
             if not self.model_tester.is_training:
                    return

             a_ :		str							=  False
             a_ :		Any							=  True

             for model_class in self.all_model_classes:
                    # we don't test BeitForMaskedImageModeling
                    if (
                        model_class in [*get_values(__snake_case					), BeitForMaskedImageModeling]
                        or not model_class.supports_gradient_checkpointing
                    ):
                           continue

                    a_ :		List[Any]							=  model_class(__snake_case					)
                    model.gradient_checkpointing_enable()
                    model.to(__snake_case					)
                    model.train()
                    a_ :		Optional[int]							=  self._prepare_for_class(__snake_case					,							__snake_case					,							return_labels=__snake_case					)
                    a_ :		int							=  model(**__snake_case					).loss
                    loss.backward()
      def 	SCREAMING_SNAKE_CASE							(	self    :	int					)		->      Optional[Any]:
             a_							,		a_ :		int							=  self.model_tester.prepare_config_and_inputs_for_common()

             a_ :		List[Any]							=  _config_zero_init(__snake_case					)
             for model_class in self.all_model_classes:
                    a_ :		str							=  model_class(config=__snake_case					)
                    for name, param in model.named_parameters():
                           # we skip lambda parameters as these require special initial values
                           # determined by config.layer_scale_init_value
                           if "lambda" in name:
                                  continue
                           if param.requires_grad:
                                  self.assertIn(
                                      ((param.data.mean() * 1E9).round() / 1E9).item()					,							[0.0, 1.0]					,							msg=F"""Parameter {name} of model {model_class} seems not properly initialized"""					,							)

      @slow
      def 	SCREAMING_SNAKE_CASE							(	self    :	List[Any]					)		->      int:
             for model_name in BEIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                    a_ :		Optional[Any]							=  BeitModel.from_pretrained(__snake_case					)
                    self.assertIsNotNone(__snake_case					)







def 	SCREAMING_SNAKE_CASE_						(      )     ->		Optional[int]:

       """simple docstring"""

       a_ :		List[Any]							=  Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'    )
       return image
@require_torch
@require_vision
class 			SCREAMING_SNAKE_CASE__  (    unittest.TestCase      ):
      @cached_property
      def 	SCREAMING_SNAKE_CASE							(	self    :	Any					)		->      Optional[int]:
             return BeitImageProcessor.from_pretrained('microsoft/beit-base-patch16-224'					) if is_vision_available() else None
      @slow
      def 	SCREAMING_SNAKE_CASE							(	self    :	Dict					)		->      str:
             a_ :		Tuple							=  BeitForMaskedImageModeling.from_pretrained('microsoft/beit-base-patch16-224-pt22k'					).to(__snake_case					)

             a_ :		Union[str, Any]							=  self.default_image_processor
             a_ :		Tuple							=  prepare_img()
             a_ :		List[str]							=  image_processor(images=__snake_case					,							return_tensors='pt'					).pixel_values.to(__snake_case					)

             # prepare bool_masked_pos
             a_ :		Tuple							=  torch.ones((1, 1_9_6)					,							dtype=torch.bool					).to(__snake_case					)

             # forward pass
             with torch.no_grad():
                    a_ :		str							=  model(pixel_values=__snake_case					,							bool_masked_pos=__snake_case					)
             a_ :		str							=  outputs.logits

             # verify the logits
             a_ :		Any							=  torch.Size((1, 1_9_6, 8_1_9_2)					)
             self.assertEqual(logits.shape					,							__snake_case					)

             a_ :		Tuple							=  torch.tensor(
                 [[-3.2437, 0.5072, -13.9174], [-3.2456, 0.4948, -13.9401], [-3.2033, 0.5121, -13.8550]]					).to(__snake_case					)

             self.assertTrue(torch.allclose(logits[bool_masked_pos][:3, :3]					,							__snake_case					,							atol=1E-2					)					)
      @slow
      def 	SCREAMING_SNAKE_CASE							(	self    :	List[Any]					)		->      Union[str, Any]:
             a_ :		List[Any]							=  BeitForImageClassification.from_pretrained('microsoft/beit-base-patch16-224'					).to(__snake_case					)

             a_ :		Optional[int]							=  self.default_image_processor
             a_ :		Optional[Any]							=  prepare_img()
             a_ :		Tuple							=  image_processor(images=__snake_case					,							return_tensors='pt'					).to(__snake_case					)

             # forward pass
             with torch.no_grad():
                    a_ :		Optional[Any]							=  model(**__snake_case					)
             a_ :		Union[str, Any]							=  outputs.logits

             # verify the logits
             a_ :		int							=  torch.Size((1, 1_0_0_0)					)
             self.assertEqual(logits.shape					,							__snake_case					)

             a_ :		Dict							=  torch.tensor([-1.2385, -1.0987, -1.0108]					).to(__snake_case					)

             self.assertTrue(torch.allclose(logits[0, :3]					,							__snake_case					,							atol=1E-4					)					)

             a_ :		Union[str, Any]							=  2_8_1
             self.assertEqual(logits.argmax(-1					).item()					,							__snake_case					)
      @slow
      def 	SCREAMING_SNAKE_CASE							(	self    :	Tuple					)		->      int:
             a_ :		Tuple							=  BeitForImageClassification.from_pretrained('microsoft/beit-large-patch16-224-pt22k-ft22k'					).to(
                 __snake_case					)

             a_ :		Optional[int]							=  self.default_image_processor
             a_ :		Dict							=  prepare_img()
             a_ :		List[Any]							=  image_processor(images=__snake_case					,							return_tensors='pt'					).to(__snake_case					)

             # forward pass
             with torch.no_grad():
                    a_ :		List[str]							=  model(**__snake_case					)
             a_ :		Tuple							=  outputs.logits

             # verify the logits
             a_ :		Dict							=  torch.Size((1, 2_1_8_4_1)					)
             self.assertEqual(logits.shape					,							__snake_case					)

             a_ :		Tuple							=  torch.tensor([1.6881, -0.2787, 0.5901]					).to(__snake_case					)

             self.assertTrue(torch.allclose(logits[0, :3]					,							__snake_case					,							atol=1E-4					)					)

             a_ :		List[str]							=  2_3_9_6
             self.assertEqual(logits.argmax(-1					).item()					,							__snake_case					)
      @slow
      def 	SCREAMING_SNAKE_CASE							(	self    :	Optional[int]					)		->      Union[str, Any]:
             a_ :		Union[str, Any]							=  BeitForSemanticSegmentation.from_pretrained('microsoft/beit-base-finetuned-ade-640-640'					)
             a_ :		Dict							=  model.to(__snake_case					)

             a_ :		List[str]							=  BeitImageProcessor(do_resize=__snake_case					,							size=6_4_0					,							do_center_crop=__snake_case					)

             a_ :		Any							=  load_dataset('hf-internal-testing/fixtures_ade20k'					,							split='test'					)
             a_ :		List[Any]							=  Image.open(ds[0]['file']					)
             a_ :		Tuple							=  image_processor(images=__snake_case					,							return_tensors='pt'					).to(__snake_case					)

             # forward pass
             with torch.no_grad():
                    a_ :		int							=  model(**__snake_case					)
             a_ :		Optional[int]							=  outputs.logits

             # verify the logits
             a_ :		Optional[Any]							=  torch.Size((1, 1_5_0, 1_6_0, 1_6_0)					)
             self.assertEqual(logits.shape					,							__snake_case					)

             a_ :		Optional[Any]							=  version.parse(PIL.__version__					) < version.parse('9.0.0'					)

             if is_pillow_less_than_a:
                    a_ :		int							=  torch.tensor(
                        [
                            [[-4.9225, -2.3954, -3.0522], [-2.8822, -1.0046, -1.7561], [-2.9549, -1.3228, -2.1347]],
                            [[-5.8168, -3.4129, -4.0778], [-3.8651, -2.2214, -3.0277], [-3.8356, -2.4643, -3.3535]],
                            [[-0.0078, 3.9952, 4.0754], [2.9856, 4.6944, 5.0035], [3.2413, 4.7813, 4.9969]],
                        ]					,							device=__snake_case					,							)
             else:
                    a_ :		Tuple							=  torch.tensor(
                        [
                            [[-4.8960, -2.3688, -3.0355], [-2.8478, -0.9836, -1.7418], [-2.9449, -1.3332, -2.1456]],
                            [[-5.8081, -3.4124, -4.1006], [-3.8561, -2.2081, -3.0323], [-3.8365, -2.4601, -3.3669]],
                            [[-0.0309, 3.9868, 4.0540], [2.9640, 4.6877, 4.9976], [3.2081, 4.7690, 4.9942]],
                        ]					,							device=__snake_case					,							)

             self.assertTrue(torch.allclose(logits[0, :3, :3, :3]					,							__snake_case					,							atol=1E-4					)					)

      @slow
      def 	SCREAMING_SNAKE_CASE							(	self    :	List[str]					)		->      Any:
             a_ :		str							=  BeitForSemanticSegmentation.from_pretrained('microsoft/beit-base-finetuned-ade-640-640'					)
             a_ :		Union[str, Any]							=  model.to(__snake_case					)

             a_ :		Union[str, Any]							=  BeitImageProcessor(do_resize=__snake_case					,							size=6_4_0					,							do_center_crop=__snake_case					)

             a_ :		Optional[Any]							=  load_dataset('hf-internal-testing/fixtures_ade20k'					,							split='test'					)
             a_ :		str							=  Image.open(ds[0]['file']					)
             a_ :		Optional[Any]							=  image_processor(images=__snake_case					,							return_tensors='pt'					).to(__snake_case					)

             # forward pass
             with torch.no_grad():
                    a_ :		Tuple							=  model(**__snake_case					)

             a_ :		List[Any]							=  outputs.logits.detach().cpu()

             a_ :		Dict							=  image_processor.post_process_semantic_segmentation(outputs=__snake_case					,							target_sizes=[(5_0_0, 3_0_0)]					)
             a_ :		Optional[int]							=  torch.Size((5_0_0, 3_0_0)					)
             self.assertEqual(segmentation[0].shape					,							__snake_case					)

             a_ :		List[str]							=  image_processor.post_process_semantic_segmentation(outputs=__snake_case					)
             a_ :		Union[str, Any]							=  torch.Size((1_6_0, 1_6_0)					)
             self.assertEqual(segmentation[0].shape					,							__snake_case					)






def 	SCREAMING_SNAKE_CASE_						(      __A			:      int    )     ->		int:

       """simple docstring"""

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

              return sequence[n]







def 	SCREAMING_SNAKE_CASE_						(      __A			:      int    )     ->		int:

       """simple docstring"""

       a_ :		Any							=  0
       a_ :		Optional[Any]							=  2

       while digits < n:
              index += 1
              a_ :		List[Any]							=  len(str(fibonacci(__A    )    )    )

       return index







def 	SCREAMING_SNAKE_CASE_						(      __A			:      int = 10_00    )     ->		int:

       """simple docstring"""

       return fibonacci_digits_index(__A    )


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


