


import inspect
import unittest

from transformers import MobileNetVaConfig
from transformers.testing_utils import require_torch, 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, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
 import torch

 from transformers import MobileNetVaForImageClassification, MobileNetVaForSemanticSegmentation, MobileNetVaModel
 from transformers.models.mobilenet_va.modeling_mobilenet_va import MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
 from PIL import Image

 from transformers import MobileNetVaImageProcessor






class _lowerCamelCase(		_a  ):
       def      UpperCamelCase	(   self)			->  List[str]:




           """simple docstring"""

           _lowercase			:				Optional[int] 						=						self.config_class(**self.inputs_dict)
           self.parent.assertTrue(hasattr(lowerCamelCase, 'tf_padding'))
           self.parent.assertTrue(hasattr(lowerCamelCase, 'depth_multiplier'))






class _lowerCamelCase:
       def __init__(   self, lowerCamelCase, lowerCamelCase=13, lowerCamelCase=3, lowerCamelCase=32, lowerCamelCase=0.2_5, lowerCamelCase=8, lowerCamelCase=8, lowerCamelCase=6, lowerCamelCase=32, lowerCamelCase=True, lowerCamelCase=True, lowerCamelCase=True, lowerCamelCase="relu6", lowerCamelCase=12_80, lowerCamelCase=0.1, lowerCamelCase=0.0_2, lowerCamelCase=True, lowerCamelCase=True, lowerCamelCase=10, lowerCamelCase=None, )			->  Any:




           """simple docstring"""

           _lowercase			:				Union[str, Any] 						=						parent
           _lowercase			:				List[str] 						=						batch_size
           _lowercase			:				str 						=						num_channels
           _lowercase			:				List[str] 						=						image_size
           _lowercase			:				Optional[int] 						=						depth_multiplier
           _lowercase			:				str 						=						depth_divisible_by
           _lowercase			:				List[Any] 						=						min_depth
           _lowercase			:				str 						=						expand_ratio
           _lowercase			:				Any 						=						tf_padding
           _lowercase			:				int 						=						output_stride
           _lowercase			:				Optional[Any] 						=						first_layer_is_expansion
           _lowercase			:				str 						=						finegrained_output
           _lowercase			:				List[str] 						=						hidden_act
           _lowercase			:				List[Any] 						=						last_hidden_size if finegrained_output else int(last_hidden_size * depth_multiplier)
           _lowercase			:				Tuple 						=						classifier_dropout_prob
           _lowercase			:				Union[str, Any] 						=						use_labels
           _lowercase			:				int 						=						is_training
           _lowercase			:				List[Any] 						=						num_labels
           _lowercase			:				List[Any] 						=						initializer_range
           _lowercase			:				Any 						=						scope
       def      UpperCamelCase	(   self)			->  Optional[Any]:




           """simple docstring"""

           _lowercase			:				List[str] 						=						floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size])

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

           _lowercase			:				Dict 						=						self.get_config()

           return config, pixel_values, labels, pixel_labels
       def      UpperCamelCase	(   self)			->  Union[str, Any]:




           """simple docstring"""

           return MobileNetVaConfig(
               num_channels=self.num_channels, image_size=self.image_size, depth_multiplier=self.depth_multiplier, depth_divisible_by=self.depth_divisible_by, min_depth=self.min_depth, expand_ratio=self.expand_ratio, output_stride=self.output_stride, first_layer_is_expansion=self.first_layer_is_expansion, finegrained_output=self.finegrained_output, hidden_act=self.hidden_act, tf_padding=self.tf_padding, classifier_dropout_prob=self.classifier_dropout_prob, initializer_range=self.initializer_range, )
       def      UpperCamelCase	(   self, lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase)			->  Tuple:




           """simple docstring"""

           _lowercase			:				int 						=						MobileNetVaModel(config=lowerCamelCase)
           model.to(lowerCamelCase)
           model.eval()
           _lowercase			:				Optional[int] 						=						model(lowerCamelCase)
           self.parent.assertEqual(
               result.last_hidden_state.shape, (
                   self.batch_size,
                   self.last_hidden_size,
                   self.image_size // self.output_stride,
                   self.image_size // self.output_stride,
               ), )
           self.parent.assertEqual(
               result.pooler_output.shape, (self.batch_size, self.last_hidden_size), )
       def      UpperCamelCase	(   self, lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase)			->  Tuple:




           """simple docstring"""

           _lowercase			:				Dict 						=						self.num_labels
           _lowercase			:				Dict 						=						MobileNetVaForImageClassification(lowerCamelCase)
           model.to(lowerCamelCase)
           model.eval()
           _lowercase			:				str 						=						model(lowerCamelCase, labels=lowerCamelCase)
           self.parent.assertEqual(result.logits.shape, (self.batch_size, self.num_labels))
       def      UpperCamelCase	(   self, lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase)			->  Any:




           """simple docstring"""

           _lowercase			:				str 						=						self.num_labels
           _lowercase			:				List[str] 						=						MobileNetVaForSemanticSegmentation(lowerCamelCase)
           model.to(lowerCamelCase)
           model.eval()
           _lowercase			:				Any 						=						model(lowerCamelCase)
           self.parent.assertEqual(
               result.logits.shape, (
                   self.batch_size,
                   self.num_labels,
                   self.image_size // self.output_stride,
                   self.image_size // self.output_stride,
               ), )
           _lowercase			:				List[Any] 						=						model(lowerCamelCase, labels=lowerCamelCase)
           self.parent.assertEqual(
               result.logits.shape, (
                   self.batch_size,
                   self.num_labels,
                   self.image_size // self.output_stride,
                   self.image_size // self.output_stride,
               ), )




       def      UpperCamelCase	(   self)			->  int:




           """simple docstring"""

           _lowercase			:				Tuple 						=						self.prepare_config_and_inputs()
           _lowercase						,							_lowercase						,							_lowercase						,							_lowercase			:				Dict 						=						config_and_inputs
           _lowercase			:				str 						=						{'pixel_values': pixel_values}
           return config, inputs_dict






@require_torch
class _lowerCamelCase(		_a,					_a,					unittest.TestCase  ):
       lowercase_					:      Union[str, Any]       					=     (
           (MobileNetVaModel, MobileNetVaForImageClassification, MobileNetVaForSemanticSegmentation)
           if is_torch_available()
           else ()
       )
       lowercase_					:      Optional[Any]       					=     (
           {
               """feature-extraction""": MobileNetVaModel,
               """image-classification""": MobileNetVaForImageClassification,
               """image-segmentation""": MobileNetVaForSemanticSegmentation,
           }
           if is_torch_available()
           else {}
       )

       lowercase_					:      Optional[Any]       					=     False
       lowercase_					:      List[Any]       					=     False
       lowercase_					:      Dict       					=     False
       lowercase_					:      List[str]       					=     False
       def      UpperCamelCase	(   self)			->  int:




           """simple docstring"""

           _lowercase			:				int 						=						MobileNetVaModelTester(self)
           _lowercase			:				Tuple 						=						MobileNetVaConfigTester(self, config_class=lowerCamelCase, has_text_modality=lowerCamelCase)
       def      UpperCamelCase	(   self)			->  Optional[Any]:




           """simple docstring"""

           self.config_tester.run_common_tests()
       @unittest.skip(reason='MobileNetV2 does not use inputs_embeds')
       def      UpperCamelCase	(   self)			->  Union[str, Any]:




           """simple docstring"""

           pass
       @unittest.skip(reason='MobileNetV2 does not support input and output embeddings')
       def      UpperCamelCase	(   self)			->  Any:




           """simple docstring"""

           pass
       @unittest.skip(reason='MobileNetV2 does not output attentions')
       def      UpperCamelCase	(   self)			->  List[str]:




           """simple docstring"""

           pass
       def      UpperCamelCase	(   self)			->  Optional[int]:




           """simple docstring"""

           _lowercase						,							_lowercase			:				int 						=						self.model_tester.prepare_config_and_inputs_for_common()

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

               _lowercase			:				List[str] 						=						['pixel_values']
               self.assertListEqual(arg_names[:1], lowerCamelCase)
       def      UpperCamelCase	(   self)			->  List[Any]:




           """simple docstring"""

           _lowercase			:				Optional[Any] 						=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*lowerCamelCase)
       def      UpperCamelCase	(   self)			->  Any:




           """simple docstring"""

           def check_hidden_states_output(lowerCamelCase, lowerCamelCase, lowerCamelCase):
               _lowercase			:				Dict 						=						model_class(lowerCamelCase)
               model.to(lowerCamelCase)
               model.eval()

               with torch.no_grad():
                   _lowercase			:				str 						=						model(**self._prepare_for_class(lowerCamelCase, lowerCamelCase))

               _lowercase			:				str 						=						outputs.hidden_states

               _lowercase			:				Union[str, Any] 						=						16
               self.assertEqual(len(lowerCamelCase), lowerCamelCase)

           _lowercase						,							_lowercase			:				Optional[int] 						=						self.model_tester.prepare_config_and_inputs_for_common()

           for model_class in self.all_model_classes:
               _lowercase			:				str 						=						True
               check_hidden_states_output(lowerCamelCase, lowerCamelCase, lowerCamelCase)

               # check that output_hidden_states also work using config
               del inputs_dict["output_hidden_states"]
               _lowercase			:				int 						=						True

               check_hidden_states_output(lowerCamelCase, lowerCamelCase, lowerCamelCase)
       def      UpperCamelCase	(   self)			->  Optional[Any]:




           """simple docstring"""

           _lowercase			:				Tuple 						=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_image_classification(*lowerCamelCase)
       def      UpperCamelCase	(   self)			->  Any:




           """simple docstring"""

           _lowercase			:				Optional[Any] 						=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_semantic_segmentation(*lowerCamelCase)




       @slow
       def      UpperCamelCase	(   self)			->  Optional[int]:




           """simple docstring"""

           for model_name in MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               _lowercase			:				List[str] 						=						MobileNetVaModel.from_pretrained(lowerCamelCase)
               self.assertIsNotNone(lowerCamelCase)



def 							UpperCamelCase_( )       ->		Optional[int]:
    _lowercase			:				Union[str, Any] 						=						Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'					)
    return image






@require_torch
@require_vision
class _lowerCamelCase(		unittest.TestCase  ):
       @cached_property
       def      UpperCamelCase	(   self)			->  Dict:




           """simple docstring"""

           return (
               MobileNetVaImageProcessor.from_pretrained('google/mobilenet_v2_1.0_224') if is_vision_available() else None
           )
       @slow
       def      UpperCamelCase	(   self)			->  List[str]:




           """simple docstring"""

           _lowercase			:				str 						=						MobileNetVaForImageClassification.from_pretrained('google/mobilenet_v2_1.0_224').to(lowerCamelCase)

           _lowercase			:				Union[str, Any] 						=						self.default_image_processor
           _lowercase			:				Tuple 						=						prepare_img()
           _lowercase			:				Union[str, Any] 						=						image_processor(images=lowerCamelCase, return_tensors='pt').to(lowerCamelCase)

           # forward pass
           with torch.no_grad():
               _lowercase			:				List[Any] 						=						model(**lowerCamelCase)

           # verify the logits
           _lowercase			:				Union[str, Any] 						=						torch.Size((1, 10_01))
           self.assertEqual(outputs.logits.shape, lowerCamelCase)

           _lowercase			:				str 						=						torch.tensor([0.2_4_4_5, -1.1_9_9_3, 0.1_9_0_5]).to(lowerCamelCase)

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




       @slow
       def      UpperCamelCase	(   self)			->  List[Any]:




           """simple docstring"""

           _lowercase			:				Optional[Any] 						=						MobileNetVaForSemanticSegmentation.from_pretrained('google/deeplabv3_mobilenet_v2_1.0_513')
           _lowercase			:				Union[str, Any] 						=						model.to(lowerCamelCase)

           _lowercase			:				int 						=						MobileNetVaImageProcessor.from_pretrained('google/deeplabv3_mobilenet_v2_1.0_513')

           _lowercase			:				Tuple 						=						prepare_img()
           _lowercase			:				Any 						=						image_processor(images=lowerCamelCase, return_tensors='pt').to(lowerCamelCase)

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

           # verify the logits
           _lowercase			:				Any 						=						torch.Size((1, 21, 65, 65))
           self.assertEqual(logits.shape, lowerCamelCase)

           _lowercase			:				Optional[int] 						=						torch.tensor(
               [
                   [[1_7.5_7_9_0, 1_7.7_5_8_1, 1_8.3_3_5_5], [1_8.3_2_5_7, 1_8.4_2_3_0, 1_8.8_9_7_3], [1_8.6_1_6_9, 1_8.8_6_5_0, 1_9.2_1_8_7]],
                   [[-2.1_5_9_5, -2.0_9_7_7, -2.3_7_4_1], [-2.4_2_2_6, -2.3_0_2_8, -2.6_8_3_5], [-2.7_8_1_9, -2.5_9_9_1, -2.7_7_0_6]],
                   [[4.2_0_5_8, 4.8_3_1_7, 4.7_6_3_8], [4.4_1_3_6, 5.0_3_6_1, 4.9_3_8_3], [4.5_0_2_8, 4.9_6_4_4, 4.8_7_3_4]],
               ], device=lowerCamelCase, )

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






def 							UpperCamelCase_( lowerCamelCase_					)       ->		int:
    if n == 1 or not isinstance(lowerCamelCase_				,					lowerCamelCase_					):
        return 0
    elif n == 2:
        return 1
    else:
        _lowercase			:				List[str] 						=						[0, 1]
        for i in range(2				,					n + 1					):
            sequence.append(sequence[i - 1] + sequence[i - 2]					)

        return sequence[n]



def 							UpperCamelCase_( lowerCamelCase_					)       ->		int:
    _lowercase			:				Tuple 						=						0
    _lowercase			:				List[str] 						=						2

    while digits < n:
        index += 1
        _lowercase			:				Optional[int] 						=						len(str(fibonacci(lowerCamelCase_					)					)					)

    return index



def 							UpperCamelCase_( lowerCamelCase_ = 1000					)       ->		int:
    return fibonacci_digits_index(lowerCamelCase_					)


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


