





'''simple docstring'''

import shutil
import tempfile
import unittest

import numpy as np
import pytest

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


if is_torch_available():
			from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
			lowerCAmelCase__      :   Optional[int]      	=			False

if is_vision_available():
			from PIL import Image

			from transformers import (
			    AutoProcessor,
			    PixaStructImageProcessor,
			    PixaStructProcessor,
			    PreTrainedTokenizerFast,
			    TaTokenizer,
			)


@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11							,reason='''`Pix2StructImageProcessor` requires `torch>=1.11.0`.'''							,)
@require_vision
@require_torch
class      SCREAMING_SNAKE_CASE__      (   unittest.TestCase		):







					"""simple docstring"""






					def 		lowerCamelCase_   (   self       :      Tuple		):







							"""simple docstring"""
							__UpperCAmelCase	:							List[str]     =     tempfile.mkdtemp()

							__UpperCAmelCase	:							Tuple     =     PixaStructImageProcessor()
							__UpperCAmelCase	:							Dict     =     TaTokenizer.from_pretrained("t5-small"		)

							__UpperCAmelCase	:							Optional[Any]     =     PixaStructProcessor(UpperCAmelCase_		,	UpperCAmelCase_		)

							processor.save_pretrained(self.tmpdirname		)
					def 		lowerCamelCase_   (   self       :      Any		,	**UpperCAmelCase_       :      Any		):







							"""simple docstring"""
							return AutoProcessor.from_pretrained(self.tmpdirname		,	**UpperCAmelCase_		).tokenizer
					def 		lowerCamelCase_   (   self       :      Optional[Any]		,	**UpperCAmelCase_       :      Any		):







							"""simple docstring"""
							return AutoProcessor.from_pretrained(self.tmpdirname		,	**UpperCAmelCase_		).image_processor
					def 		lowerCamelCase_   (   self       :      Union[str, Any]		):







							"""simple docstring"""
							shutil.rmtree(self.tmpdirname		)
					def 		lowerCamelCase_   (   self       :      Dict		):







							"""simple docstring"""
							__UpperCAmelCase	:							Optional[Any]     =     [np.random.randint(255		,	size=(3, 30, 400)		,	dtype=np.uinta		)]

							__UpperCAmelCase	:							Any     =     [Image.fromarray(np.moveaxis(UpperCAmelCase_		,	0		,	-1		)		) for x in image_inputs]

							return image_inputs
					def 		lowerCamelCase_   (   self       :      List[Any]		):







							"""simple docstring"""
							__UpperCAmelCase	:							Dict     =     PixaStructProcessor(tokenizer=self.get_tokenizer()		,	image_processor=self.get_image_processor()		)
							processor.save_pretrained(self.tmpdirname		)

							__UpperCAmelCase	:							Any     =     self.get_tokenizer(bos_token="(BOS)"		,	eos_token="(EOS)"		)
							__UpperCAmelCase	:							Dict     =     self.get_image_processor(do_normalize=UpperCAmelCase_		,	padding_value=1.0		)

							__UpperCAmelCase	:							Any     =     PixaStructProcessor.from_pretrained(
							    self.tmpdirname		,	bos_token="(BOS)"		,	eos_token="(EOS)"		,	do_normalize=UpperCAmelCase_		,	padding_value=1.0		)

							self.assertEqual(processor.tokenizer.get_vocab()		,	tokenizer_add_kwargs.get_vocab()		)
							self.assertIsInstance(processor.tokenizer		,	UpperCAmelCase_		)

							self.assertEqual(processor.image_processor.to_json_string()		,	image_processor_add_kwargs.to_json_string()		)
							self.assertIsInstance(processor.image_processor		,	UpperCAmelCase_		)
					def 		lowerCamelCase_   (   self       :      Optional[int]		):







							"""simple docstring"""
							__UpperCAmelCase	:							int     =     self.get_image_processor()
							__UpperCAmelCase	:							Dict     =     self.get_tokenizer()

							__UpperCAmelCase	:							List[Any]     =     PixaStructProcessor(tokenizer=UpperCAmelCase_		,	image_processor=UpperCAmelCase_		)

							__UpperCAmelCase	:							Union[str, Any]     =     self.prepare_image_inputs()

							__UpperCAmelCase	:							Any     =     image_processor(UpperCAmelCase_		,	return_tensors="np"		)
							__UpperCAmelCase	:							Tuple     =     processor(images=UpperCAmelCase_		,	return_tensors="np"		)

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







							"""simple docstring"""
							__UpperCAmelCase	:							Union[str, Any]     =     self.get_image_processor()
							__UpperCAmelCase	:							Any     =     self.get_tokenizer()

							__UpperCAmelCase	:							Optional[int]     =     PixaStructProcessor(tokenizer=UpperCAmelCase_		,	image_processor=UpperCAmelCase_		)

							__UpperCAmelCase	:							Optional[Any]     =     "lower newer"

							__UpperCAmelCase	:							Tuple     =     processor(text=UpperCAmelCase_		)

							__UpperCAmelCase	:							List[Any]     =     tokenizer(UpperCAmelCase_		,	return_token_type_ids=UpperCAmelCase_		,	add_special_tokens=UpperCAmelCase_		)

							for key in encoded_tok.keys():
									self.assertListEqual(encoded_tok[key]		,	encoded_processor[key]		)
					def 		lowerCamelCase_   (   self       :      str		):







							"""simple docstring"""
							__UpperCAmelCase	:							Any     =     self.get_image_processor()
							__UpperCAmelCase	:							List[str]     =     self.get_tokenizer()

							__UpperCAmelCase	:							List[Any]     =     PixaStructProcessor(tokenizer=UpperCAmelCase_		,	image_processor=UpperCAmelCase_		)

							__UpperCAmelCase	:							Optional[int]     =     "lower newer"
							__UpperCAmelCase	:							Tuple     =     self.prepare_image_inputs()

							__UpperCAmelCase	:							Optional[Any]     =     processor(text=UpperCAmelCase_		,	images=UpperCAmelCase_		)

							self.assertListEqual(
							    list(inputs.keys()		)		,	["flattened_patches", "attention_mask", "decoder_attention_mask", "decoder_input_ids"]		)

							# test if it raises when no input is passed
							with pytest.raises(UpperCAmelCase_		):
									processor()
					def 		lowerCamelCase_   (   self       :      List[str]		):







							"""simple docstring"""
							__UpperCAmelCase	:							Tuple     =     self.get_image_processor()
							__UpperCAmelCase	:							Optional[int]     =     self.get_tokenizer()

							__UpperCAmelCase	:							List[str]     =     PixaStructProcessor(tokenizer=UpperCAmelCase_		,	image_processor=UpperCAmelCase_		)

							__UpperCAmelCase	:							Union[str, Any]     =     "lower newer"
							__UpperCAmelCase	:							Dict     =     self.prepare_image_inputs()

							__UpperCAmelCase	:							Dict     =     processor(text=UpperCAmelCase_		,	images=UpperCAmelCase_		)

							__UpperCAmelCase	:							Optional[Any]     =     [512, 1_024, 2_048, 4_096]
							__UpperCAmelCase	:							Dict     =     [770, 770, 770, 770]
							# with text
							for i, max_patch in enumerate(UpperCAmelCase_		):
									__UpperCAmelCase	:							Optional[Any]     =     processor(text=UpperCAmelCase_		,	images=UpperCAmelCase_		,	max_patches=UpperCAmelCase_		)
									self.assertEqual(inputs["flattened_patches"][0].shape[0]		,	UpperCAmelCase_		)
									self.assertEqual(inputs["flattened_patches"][0].shape[1]		,	expected_hidden_size[i]		)

							# without text input
							for i, max_patch in enumerate(UpperCAmelCase_		):
									__UpperCAmelCase	:							List[str]     =     processor(images=UpperCAmelCase_		,	max_patches=UpperCAmelCase_		)
									self.assertEqual(inputs["flattened_patches"][0].shape[0]		,	UpperCAmelCase_		)
									self.assertEqual(inputs["flattened_patches"][0].shape[1]		,	expected_hidden_size[i]		)
					def 		lowerCamelCase_   (   self       :      str		):







							"""simple docstring"""
							__UpperCAmelCase	:							Optional[int]     =     self.get_image_processor()
							__UpperCAmelCase	:							Union[str, Any]     =     self.get_tokenizer()

							__UpperCAmelCase	:							Tuple     =     PixaStructProcessor(tokenizer=UpperCAmelCase_		,	image_processor=UpperCAmelCase_		)

							__UpperCAmelCase	:							Dict     =     [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

							__UpperCAmelCase	:							Dict     =     processor.batch_decode(UpperCAmelCase_		)
							__UpperCAmelCase	:							Optional[int]     =     tokenizer.batch_decode(UpperCAmelCase_		)

							self.assertListEqual(UpperCAmelCase_		,	UpperCAmelCase_		)






					def 		lowerCamelCase_   (   self       :      Optional[int]		):







							"""simple docstring"""
							__UpperCAmelCase	:							Optional[int]     =     self.get_image_processor()
							__UpperCAmelCase	:							Any     =     self.get_tokenizer()

							__UpperCAmelCase	:							Any     =     PixaStructProcessor(tokenizer=UpperCAmelCase_		,	image_processor=UpperCAmelCase_		)

							__UpperCAmelCase	:							int     =     "lower newer"
							__UpperCAmelCase	:							str     =     self.prepare_image_inputs()

							__UpperCAmelCase	:							str     =     processor(text=UpperCAmelCase_		,	images=UpperCAmelCase_		)

							# For now the processor supports only ["flattened_patches", "input_ids", "attention_mask", "decoder_attention_mask"]
							self.assertListEqual(
							    list(inputs.keys()		)		,	["flattened_patches", "attention_mask", "decoder_attention_mask", "decoder_input_ids"]		)

							__UpperCAmelCase	:							Optional[int]     =     processor(text=UpperCAmelCase_		)

							# For now the processor supports only ["flattened_patches", "input_ids", "attention_mask", "decoder_attention_mask"]
							self.assertListEqual(list(inputs.keys()		)		,	["input_ids", "attention_mask"]		)











'''simple docstring'''

from __future__ import annotations

lowerCAmelCase__      :   Tuple      	=			{1: 1}


def 						__UpperCamelCase						(			_UpperCAmelCase  ):
		if n in COLLATZ_SEQUENCE_LENGTHS:
				return COLLATZ_SEQUENCE_LENGTHS[n]
		__UpperCAmelCase	:							int     =     n // 2 if n % 2 == 0 else 3 * n + 1
		__UpperCAmelCase	:							str     =     collatz_sequence_length(_UpperCAmelCase  ) + 1
		__UpperCAmelCase	:							Union[str, Any]     =     sequence_length
		return sequence_length


def 						__UpperCamelCase						(			_UpperCAmelCase = 1000000  ):
		__UpperCAmelCase	:							Union[str, Any]     =     max((collatz_sequence_length(_UpperCAmelCase  ), i) for i in range(1,       _UpperCAmelCase  )  )
		return result[1]


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




