
import unittest

import numpy as np
import requests

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
  import torch

  from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
  lowercase  : int						   =							False

if is_vision_available():
  from PIL import Image

  from transformers import PixaStructImageProcessor

class __snake_case		(				unittest.TestCase					):
    def __init__(  self		,snake_case		,snake_case=7		,snake_case=3		,snake_case=18		,snake_case=30		,snake_case=400		,snake_case=None		,snake_case=True		,snake_case=True		,snake_case=None		,):



           '''simple docstring'''







           lowercase							:					List[Any]	     =				size if size is not None else {"""height""": 20, """width""": 20}
           lowercase							:					List[Any]	     =				parent
           lowercase							:					List[str]	     =				batch_size
           lowercase							:					Optional[Any]	     =				num_channels
           lowercase							:					Any	     =				image_size
           lowercase							:					Union[str, Any]	     =				min_resolution
           lowercase							:					Optional[Any]	     =				max_resolution
           lowercase							:					List[Any]	     =				size
           lowercase							:					Dict	     =				do_normalize
           lowercase							:					str	     =				do_convert_rgb
           lowercase							:					Optional[Any]	     =				[512, 1024, 2048, 4096]
           lowercase							:					int	     =				patch_size if patch_size is not None else {"""height""": 16, """width""": 16}
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           return {"do_normalize": self.do_normalize, "do_convert_rgb": self.do_convert_rgb}
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					Dict	     =				"""https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg"""
           lowercase							:					Union[str, Any]	     =				Image.open(requests.get(snake_case		,stream=snake_case				).raw				).convert("""RGB"""				)
           return raw_image






@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11 ,     reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`." ,     )
@require_torch
@require_vision
class __snake_case		(				lowerCAmelCase ,     unittest.TestCase					):
    _a		:						Optional[int]=    PixaStructImageProcessor if is_vision_available() else None
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					List[str]	     =				PixaStructImageProcessingTester(self				)
    @property
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           return self.image_processor_tester.prepare_image_processor_dict()
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					str	     =				self.image_processing_class(**self.image_processor_dict				)
           self.assertTrue(hasattr(snake_case		,"""do_normalize"""				)				)
           self.assertTrue(hasattr(snake_case		,"""do_convert_rgb"""				)				)
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					Any	     =				self.image_processor_tester.prepare_dummy_image()

           lowercase							:					List[str]	     =				self.image_processing_class(**self.image_processor_dict				)
           lowercase							:					Tuple	     =				2048

           lowercase							:					Dict	     =				image_processor(snake_case		,return_tensors="""pt"""		,max_patches=snake_case				)
           self.assertTrue(torch.allclose(inputs.flattened_patches.mean()		,torch.tensor(0.0_606				)		,atol=1e-3		,rtol=1e-3				)				)
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					str	     =				self.image_processing_class(**self.image_processor_dict				)
           # create random PIL images
           lowercase							:					Optional[int]	     =				prepare_image_inputs(self.image_processor_tester		,equal_resolution=snake_case				)
           for image in image_inputs:
                  self.assertIsInstance(snake_case		,Image.Image				)

           # Test not batched input
           lowercase							:					Any	     =				(
               (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
               * self.image_processor_tester.num_channels
           ) + 2

           for max_patch in self.image_processor_tester.max_patches:
                  # Test not batched input
                  lowercase							:					List[Any]	     =				image_processor(
                      image_inputs[0]		,return_tensors="""pt"""		,max_patches=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(1, max_patch, expected_hidden_dim)		,)

                  # Test batched
                  lowercase							:					str	     =				image_processor(
                      snake_case		,return_tensors="""pt"""		,max_patches=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)		,)
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					List[Any]	     =				self.image_processing_class(**self.image_processor_dict				)
           # create random PIL images
           lowercase							:					Tuple	     =				prepare_image_inputs(self.image_processor_tester		,equal_resolution=snake_case				)
           for image in image_inputs:
                  self.assertIsInstance(snake_case		,Image.Image				)

           # Test not batched input
           lowercase							:					int	     =				(
               (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
               * self.image_processor_tester.num_channels
           ) + 2

           lowercase							:					List[Any]	     =				True

           for max_patch in self.image_processor_tester.max_patches:
                  # Test not batched input
                  with self.assertRaises(snake_case				):
                         lowercase							:					Tuple	     =				image_processor(
                             image_inputs[0]		,return_tensors="""pt"""		,max_patches=snake_case				).flattened_patches

                  lowercase							:					Optional[int]	     =				"""Hello"""

                  lowercase							:					List[Any]	     =				image_processor(
                      image_inputs[0]		,return_tensors="""pt"""		,max_patches=snake_case		,header_text=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(1, max_patch, expected_hidden_dim)		,)

                  # Test batched
                  lowercase							:					Tuple	     =				image_processor(
                      snake_case		,return_tensors="""pt"""		,max_patches=snake_case		,header_text=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)		,)
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					Optional[Any]	     =				self.image_processing_class(**self.image_processor_dict				)
           # create random numpy tensors
           lowercase							:					Tuple	     =				prepare_image_inputs(self.image_processor_tester		,equal_resolution=snake_case		,numpify=snake_case				)
           for image in image_inputs:
                  self.assertIsInstance(snake_case		,np.ndarray				)

           lowercase							:					Optional[Any]	     =				(
               (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
               * self.image_processor_tester.num_channels
           ) + 2

           for max_patch in self.image_processor_tester.max_patches:
                  # Test not batched input
                  lowercase							:					Any	     =				image_processor(
                      image_inputs[0]		,return_tensors="""pt"""		,max_patches=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(1, max_patch, expected_hidden_dim)		,)

                  # Test batched
                  lowercase							:					Dict	     =				image_processor(
                      snake_case		,return_tensors="""pt"""		,max_patches=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)		,)
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					Dict	     =				self.image_processing_class(**self.image_processor_dict				)
           # create random PyTorch tensors
           lowercase							:					Optional[Any]	     =				prepare_image_inputs(self.image_processor_tester		,equal_resolution=snake_case		,torchify=snake_case				)
           for image in image_inputs:
                  self.assertIsInstance(snake_case		,torch.Tensor				)

           # Test not batched input
           lowercase							:					Union[str, Any]	     =				(
               (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
               * self.image_processor_tester.num_channels
           ) + 2

           for max_patch in self.image_processor_tester.max_patches:
                  # Test not batched input
                  lowercase							:					Any	     =				image_processor(
                      image_inputs[0]		,return_tensors="""pt"""		,max_patches=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(1, max_patch, expected_hidden_dim)		,)

                  # Test batched
                  lowercase							:					Any	     =				image_processor(
                      snake_case		,return_tensors="""pt"""		,max_patches=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)		,)






@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11 ,     reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`." ,     )
@require_torch
@require_vision
class __snake_case		(				lowerCAmelCase ,     unittest.TestCase					):
    _a		:						List[Any]=    PixaStructImageProcessor if is_vision_available() else None
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					List[Any]	     =				PixaStructImageProcessingTester(self		,num_channels=4				)
           lowercase							:					Any	     =				3
    @property
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           return self.image_processor_tester.prepare_image_processor_dict()
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					Optional[int]	     =				self.image_processing_class(**self.image_processor_dict				)
           self.assertTrue(hasattr(snake_case		,"""do_normalize"""				)				)
           self.assertTrue(hasattr(snake_case		,"""do_convert_rgb"""				)				)
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







           lowercase							:					Tuple	     =				self.image_processing_class(**self.image_processor_dict				)
           # create random PIL images
           lowercase							:					Union[str, Any]	     =				prepare_image_inputs(self.image_processor_tester		,equal_resolution=snake_case				)
           for image in image_inputs:
                  self.assertIsInstance(snake_case		,Image.Image				)

           # Test not batched input
           lowercase							:					str	     =				(
               (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
               * (self.image_processor_tester.num_channels - 1)
           ) + 2

           for max_patch in self.image_processor_tester.max_patches:
                  # Test not batched input
                  lowercase							:					List[str]	     =				image_processor(
                      image_inputs[0]		,return_tensors="""pt"""		,max_patches=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(1, max_patch, expected_hidden_dim)		,)

                  # Test batched
                  lowercase							:					int	     =				image_processor(
                      snake_case		,return_tensors="""pt"""		,max_patches=snake_case				).flattened_patches
                  self.assertEqual(
                      encoded_images.shape		,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)		,)


from collections.abc import Generator







def 						_snake_case(  )			->   Generator[int, None, None]:
       lowercase     ,      lowercase							:					List[str]	     =				0, 1
       while True:
              lowercase     ,      lowercase							:					Optional[int]	     =				b, a + b
              yield b







def 						_snake_case(  SCREAMING_SNAKE_CASE__ = 1_000    )			->   int:
       lowercase							:					List[Any]	     =				1
       lowercase							:					Tuple	     =				fibonacci_generator()
       while len(str(next(SCREAMING_SNAKE_CASE__    )    )    ) < n:
              answer += 1
       return answer + 1


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