




'''simple docstring'''



import shutil
import tempfile
import unittest

import numpy as np

from transformers.testing_utils import (
    is_pt_tf_cross_test,
    require_tf,
    require_torch,
    require_torchvision,
    require_vision,
)
from transformers.utils import is_tf_available, is_torch_available, is_vision_available


if is_vision_available():
 from PIL import Image

 from transformers import AutoProcessor, SamImageProcessor, SamProcessor

if is_torch_available():
 import torch

if is_tf_available():
 import tensorflow as tf







@require_vision
@require_torchvision
class 		lowercase_   (			unittest.TestCase       ):


   """simple docstring"""

   def 							lowerCAmelCase_      (   self :     Optional[int]   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				tempfile.mkdtemp()
      _SCREAMING_SNAKE_CASE	=				SamImageProcessor()
      _SCREAMING_SNAKE_CASE	=				SamProcessor(__lowerCamelCase   )
      processor.save_pretrained(self.tmpdirname   )



   def 							lowerCAmelCase_      (   self :     int  ,				**__lowerCamelCase :     Optional[int]   ):

      """simple docstring"""
      return AutoProcessor.from_pretrained(self.tmpdirname  ,				**__lowerCamelCase   ).image_processor



   def 							lowerCAmelCase_      (   self :     Union[str, Any]   ):

      """simple docstring"""
      shutil.rmtree(self.tmpdirname   )



   def 							lowerCAmelCase_      (   self :     int   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				[np.random.randint(2_5_5  ,				size=(3, 3_0, 4_0_0)  ,				dtype=np.uinta   )]

      _SCREAMING_SNAKE_CASE	=				[Image.fromarray(np.moveaxis(__lowerCamelCase  ,				0  ,				-1   )   ) for x in image_inputs]

      return image_inputs



   def 							lowerCAmelCase_      (   self :     Optional[Any]   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				SamProcessor(image_processor=self.get_image_processor()   )
      processor.save_pretrained(self.tmpdirname   )

      _SCREAMING_SNAKE_CASE	=				self.get_image_processor(do_normalize=__lowerCamelCase  ,				padding_value=1.0   )

      _SCREAMING_SNAKE_CASE	=				SamProcessor.from_pretrained(self.tmpdirname  ,				do_normalize=__lowerCamelCase  ,				padding_value=1.0   )

      self.assertEqual(processor.image_processor.to_json_string()  ,				image_processor_add_kwargs.to_json_string()   )
      self.assertIsInstance(processor.image_processor  ,				__lowerCamelCase   )



   def 							lowerCAmelCase_      (   self :     List[Any]   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				self.get_image_processor()

      _SCREAMING_SNAKE_CASE	=				SamProcessor(image_processor=__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				self.prepare_image_inputs()

      _SCREAMING_SNAKE_CASE	=				image_processor(__lowerCamelCase  ,				return_tensors="np"   )
      _SCREAMING_SNAKE_CASE	=				processor(images=__lowerCamelCase  ,				return_tensors="np"   )

      input_feat_extract.pop("original_sizes"   )  # pop original_sizes as it is popped in the processor
      input_feat_extract.pop("reshaped_input_sizes"   )  # pop original_sizes as it is popped in the processor

      for key in input_feat_extract.keys():
         self.assertAlmostEqual(input_feat_extract[key].sum()  ,				input_processor[key].sum()  ,				delta=1e-2   )



   @require_torch
   def 							lowerCAmelCase_      (   self :     Optional[int]   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				self.get_image_processor()

      _SCREAMING_SNAKE_CASE	=				SamProcessor(image_processor=__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				[torch.ones((1, 3, 5, 5)   )]

      _SCREAMING_SNAKE_CASE	=				[[1_7_6_4, 2_6_4_6]]

      _SCREAMING_SNAKE_CASE	=				[[6_8_3, 1_0_2_4]]
      _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(__lowerCamelCase  ,				__lowerCamelCase  ,				__lowerCamelCase   )
      self.assertEqual(masks[0].shape  ,				(1, 3, 1_7_6_4, 2_6_4_6)   )

      _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(
          __lowerCamelCase  ,				torch.tensor(__lowerCamelCase   )  ,				torch.tensor(__lowerCamelCase   )   )
      self.assertEqual(masks[0].shape  ,				(1, 3, 1_7_6_4, 2_6_4_6)   )

      # should also work with np
      _SCREAMING_SNAKE_CASE	=				[np.ones((1, 3, 5, 5)   )]
      _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(__lowerCamelCase  ,				np.array(__lowerCamelCase   )  ,				np.array(__lowerCamelCase   )   )

      self.assertEqual(masks[0].shape  ,				(1, 3, 1_7_6_4, 2_6_4_6)   )

      _SCREAMING_SNAKE_CASE	=				[[1, 0], [0, 1]]
      with self.assertRaises(__lowerCamelCase   ):
         _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(__lowerCamelCase  ,				np.array(__lowerCamelCase   )  ,				np.array(__lowerCamelCase   )   )







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


   """simple docstring"""

   def 							lowerCAmelCase_      (   self :     str   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				tempfile.mkdtemp()
      _SCREAMING_SNAKE_CASE	=				SamImageProcessor()
      _SCREAMING_SNAKE_CASE	=				SamProcessor(__lowerCamelCase   )
      processor.save_pretrained(self.tmpdirname   )



   def 							lowerCAmelCase_      (   self :     Dict  ,				**__lowerCamelCase :     List[str]   ):

      """simple docstring"""
      return AutoProcessor.from_pretrained(self.tmpdirname  ,				**__lowerCamelCase   ).image_processor



   def 							lowerCAmelCase_      (   self :     int   ):

      """simple docstring"""
      shutil.rmtree(self.tmpdirname   )



   def 							lowerCAmelCase_      (   self :     Any   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				[np.random.randint(2_5_5  ,				size=(3, 3_0, 4_0_0)  ,				dtype=np.uinta   )]

      _SCREAMING_SNAKE_CASE	=				[Image.fromarray(np.moveaxis(__lowerCamelCase  ,				0  ,				-1   )   ) for x in image_inputs]

      return image_inputs



   def 							lowerCAmelCase_      (   self :     Union[str, Any]   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				SamProcessor(image_processor=self.get_image_processor()   )
      processor.save_pretrained(self.tmpdirname   )

      _SCREAMING_SNAKE_CASE	=				self.get_image_processor(do_normalize=__lowerCamelCase  ,				padding_value=1.0   )

      _SCREAMING_SNAKE_CASE	=				SamProcessor.from_pretrained(self.tmpdirname  ,				do_normalize=__lowerCamelCase  ,				padding_value=1.0   )

      self.assertEqual(processor.image_processor.to_json_string()  ,				image_processor_add_kwargs.to_json_string()   )
      self.assertIsInstance(processor.image_processor  ,				__lowerCamelCase   )



   def 							lowerCAmelCase_      (   self :     int   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				self.get_image_processor()

      _SCREAMING_SNAKE_CASE	=				SamProcessor(image_processor=__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				self.prepare_image_inputs()

      _SCREAMING_SNAKE_CASE	=				image_processor(__lowerCamelCase  ,				return_tensors="np"   )
      _SCREAMING_SNAKE_CASE	=				processor(images=__lowerCamelCase  ,				return_tensors="np"   )

      input_feat_extract.pop("original_sizes"   )  # pop original_sizes as it is popped in the processor
      input_feat_extract.pop("reshaped_input_sizes"   )  # pop reshaped_input_sizes as it is popped in the processor

      for key in input_feat_extract.keys():
         self.assertAlmostEqual(input_feat_extract[key].sum()  ,				input_processor[key].sum()  ,				delta=1e-2   )



   @require_tf
   def 							lowerCAmelCase_      (   self :     str   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				self.get_image_processor()

      _SCREAMING_SNAKE_CASE	=				SamProcessor(image_processor=__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				[tf.ones((1, 3, 5, 5)   )]

      _SCREAMING_SNAKE_CASE	=				[[1_7_6_4, 2_6_4_6]]

      _SCREAMING_SNAKE_CASE	=				[[6_8_3, 1_0_2_4]]
      _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(__lowerCamelCase  ,				__lowerCamelCase  ,				__lowerCamelCase  ,				return_tensors="tf"   )
      self.assertEqual(masks[0].shape  ,				(1, 3, 1_7_6_4, 2_6_4_6)   )

      _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(
          __lowerCamelCase  ,				tf.convert_to_tensor(__lowerCamelCase   )  ,				tf.convert_to_tensor(__lowerCamelCase   )  ,				return_tensors="tf"  ,				)
      self.assertEqual(masks[0].shape  ,				(1, 3, 1_7_6_4, 2_6_4_6)   )

      # should also work with np
      _SCREAMING_SNAKE_CASE	=				[np.ones((1, 3, 5, 5)   )]
      _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(
          __lowerCamelCase  ,				np.array(__lowerCamelCase   )  ,				np.array(__lowerCamelCase   )  ,				return_tensors="tf"   )

      self.assertEqual(masks[0].shape  ,				(1, 3, 1_7_6_4, 2_6_4_6)   )

      _SCREAMING_SNAKE_CASE	=				[[1, 0], [0, 1]]
      with self.assertRaises(tf.errors.InvalidArgumentError   ):
         _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(
             __lowerCamelCase  ,				np.array(__lowerCamelCase   )  ,				np.array(__lowerCamelCase   )  ,				return_tensors="tf"   )







@require_vision
@require_torchvision
class 		lowercase_   (			unittest.TestCase       ):


   """simple docstring"""

   def 							lowerCAmelCase_      (   self :     Optional[Any]   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				tempfile.mkdtemp()
      _SCREAMING_SNAKE_CASE	=				SamImageProcessor()
      _SCREAMING_SNAKE_CASE	=				SamProcessor(__lowerCamelCase   )
      processor.save_pretrained(self.tmpdirname   )



   def 							lowerCAmelCase_      (   self :     Tuple  ,				**__lowerCamelCase :     str   ):

      """simple docstring"""
      return AutoProcessor.from_pretrained(self.tmpdirname  ,				**__lowerCamelCase   ).image_processor



   def 							lowerCAmelCase_      (   self :     Dict   ):

      """simple docstring"""
      shutil.rmtree(self.tmpdirname   )



   def 							lowerCAmelCase_      (   self :     int   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				[np.random.randint(2_5_5  ,				size=(3, 3_0, 4_0_0)  ,				dtype=np.uinta   )]

      _SCREAMING_SNAKE_CASE	=				[Image.fromarray(np.moveaxis(__lowerCamelCase  ,				0  ,				-1   )   ) for x in image_inputs]

      return image_inputs



   @is_pt_tf_cross_test
   def 							lowerCAmelCase_      (   self :     Any   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				self.get_image_processor()

      _SCREAMING_SNAKE_CASE	=				SamProcessor(image_processor=__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				np.random.randint(0  ,				2  ,				size=(1, 3, 5, 5)   ).astype(np.floataa   )
      _SCREAMING_SNAKE_CASE	=				[tf.convert_to_tensor(__lowerCamelCase   )]
      _SCREAMING_SNAKE_CASE	=				[torch.tensor(__lowerCamelCase   )]

      _SCREAMING_SNAKE_CASE	=				[[1_7_6_4, 2_6_4_6]]

      _SCREAMING_SNAKE_CASE	=				[[6_8_3, 1_0_2_4]]
      _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(
          __lowerCamelCase  ,				__lowerCamelCase  ,				__lowerCamelCase  ,				return_tensors="tf"   )
      _SCREAMING_SNAKE_CASE	=				processor.post_process_masks(
          __lowerCamelCase  ,				__lowerCamelCase  ,				__lowerCamelCase  ,				return_tensors="pt"   )

      self.assertTrue(np.all(tf_masks[0].numpy() == pt_masks[0].numpy()   )   )



   @is_pt_tf_cross_test
   def 							lowerCAmelCase_      (   self :     str   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				self.get_image_processor()

      _SCREAMING_SNAKE_CASE	=				SamProcessor(image_processor=__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				self.prepare_image_inputs()

      _SCREAMING_SNAKE_CASE	=				image_processor(__lowerCamelCase  ,				return_tensors="pt"   )["pixel_values"].numpy()
      _SCREAMING_SNAKE_CASE	=				processor(images=__lowerCamelCase  ,				return_tensors="pt"   )["pixel_values"].numpy()

      _SCREAMING_SNAKE_CASE	=				image_processor(__lowerCamelCase  ,				return_tensors="tf"   )["pixel_values"].numpy()
      _SCREAMING_SNAKE_CASE	=				processor(images=__lowerCamelCase  ,				return_tensors="tf"   )["pixel_values"].numpy()

      self.assertTrue(np.allclose(__lowerCamelCase  ,				__lowerCamelCase   )   )
      self.assertTrue(np.allclose(__lowerCamelCase  ,				__lowerCamelCase   )   )
      self.assertTrue(np.allclose(__lowerCamelCase  ,				__lowerCamelCase   )   )







'''simple docstring'''



def 			SCREAMING_SNAKE_CASE_			(							__A    :			int  )			->			int:
   if n == 1 or not isinstance(__A	,					__A  ):
      return 0
   elif n == 2:
      return 1
   else:
      _SCREAMING_SNAKE_CASE	=				[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:
   _SCREAMING_SNAKE_CASE	=				0
   _SCREAMING_SNAKE_CASE	=				2

   while digits < n:
      index += 1
      _SCREAMING_SNAKE_CASE	=				len(str(fibonacci(__A  )  )  )

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


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

