



from typing import Dict, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image
from ...image_utils import (
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_pytesseract_available, is_vision_available, logging, requires_backends


if is_vision_available():
						import PIL

# soft dependency
if is_pytesseract_available():
						import pytesseract

_snake_case	=						logging.get_logger(__name__)






def        A       (      _lowerCamelCase       ,				_lowerCamelCase       ,				_lowerCamelCase						):





							'''simple docstring'''




							return [
							    int(1_000 * (box[0] / width)						),
							    int(1_000 * (box[1] / height)						),
							    int(1_000 * (box[2] / width)						),
							    int(1_000 * (box[3] / height)						),
							]






def        A       (      _lowerCamelCase       ,				_lowerCamelCase       ,				_lowerCamelCase = None						):





							'''simple docstring'''




							_lowerCAmelCase  :							int				     =					tesseract_config if tesseract_config is not None else ""

							# apply OCR
							_lowerCAmelCase  :							Tuple				     =					to_pil_image(_lowerCamelCase						)
							_lowerCAmelCase     ,					_lowerCAmelCase  :							int				     =					pil_image.size
							_lowerCAmelCase  :							Dict				     =					pytesseract.image_to_data(_lowerCamelCase       ,				lang=_lowerCamelCase       ,				output_type="dict"       ,				config=_lowerCamelCase						)
							_lowerCAmelCase     ,					_lowerCAmelCase     ,					_lowerCAmelCase     ,					_lowerCAmelCase     ,					_lowerCAmelCase  :							int				     =					data["text"], data["left"], data["top"], data["width"], data["height"]

							# filter empty words and corresponding coordinates
							_lowerCAmelCase  :							Dict				     =					[idx for idx, word in enumerate(_lowerCamelCase						) if not word.strip()]
							_lowerCAmelCase  :							Optional[int]				     =					[word for idx, word in enumerate(_lowerCamelCase						) if idx not in irrelevant_indices]
							_lowerCAmelCase  :							Dict				     =					[coord for idx, coord in enumerate(_lowerCamelCase						) if idx not in irrelevant_indices]
							_lowerCAmelCase  :							Dict				     =					[coord for idx, coord in enumerate(_lowerCamelCase						) if idx not in irrelevant_indices]
							_lowerCAmelCase  :							Tuple				     =					[coord for idx, coord in enumerate(_lowerCamelCase						) if idx not in irrelevant_indices]
							_lowerCAmelCase  :							Dict				     =					[coord for idx, coord in enumerate(_lowerCamelCase						) if idx not in irrelevant_indices]

							# turn coordinates into (left, top, left+width, top+height) format
							_lowerCAmelCase  :							Optional[int]				     =					[]
							for x, y, w, h in zip(_lowerCamelCase       ,				_lowerCamelCase       ,				_lowerCamelCase       ,				_lowerCamelCase						):
														_lowerCAmelCase  :							List[str]				     =					[x, y, x + w, y + h]
														actual_boxes.append(_lowerCamelCase						)

							# finally, normalize the bounding boxes
							_lowerCAmelCase  :							int				     =					[]
							for box in actual_boxes:
														normalized_boxes.append(normalize_box(_lowerCamelCase       ,				_lowerCamelCase       ,				_lowerCamelCase						)						)

							assert len(_lowerCamelCase						) == len(_lowerCamelCase						), "Not as many words as there are bounding boxes"

							return words, normalized_boxes



class 						UpperCAmelCase_					( a):
							lowerCamelCase__         =	['pixel_values']







							def __init__(     self,    __a = True,    __a = None,    __a = PILImageResampling.BILINEAR,    __a = True,    __a = None,    __a = "",    **__a,    ):

														'''simple docstring'''

														super().__init__(**__a)
														_lowerCAmelCase  :							int				     =					size if size is not None else {"height": 224, "width": 224}
														_lowerCAmelCase  :							int				     =					get_size_dict(__a)

														_lowerCAmelCase  :							Dict				     =					do_resize
														_lowerCAmelCase  :							str				     =					size
														_lowerCAmelCase  :							Optional[int]				     =					resample
														_lowerCAmelCase  :							Dict				     =					apply_ocr
														_lowerCAmelCase  :							Union[str, Any]				     =					ocr_lang
														_lowerCAmelCase  :							Any				     =					tesseract_config







							def      snake_case__   (     self,    __a,    __a,    __a = PILImageResampling.BILINEAR,    __a = None,    **__a,    ):

														'''simple docstring'''

														_lowerCAmelCase  :							Dict				     =					get_size_dict(__a)
														if "height" not in size or "width" not in size:
																					raise ValueError(f"The size dictionary must contain the keys 'height' and 'width'. Got {size.keys()}")
														_lowerCAmelCase  :							Any				     =					(size["height"], size["width"])
														return resize(__a,    size=__a,    resample=__a,    data_format=__a,    **__a)







							def      snake_case__   (     self,    __a,    __a = None,    __a = None,    __a = None,    __a = None,    __a = None,    __a = None,    __a = None,    __a = ChannelDimension.FIRST,    **__a,    ):

														'''simple docstring'''

														_lowerCAmelCase  :							int				     =					do_resize if do_resize is not None else self.do_resize
														_lowerCAmelCase  :							Tuple				     =					size if size is not None else self.size
														_lowerCAmelCase  :							Tuple				     =					get_size_dict(__a)
														_lowerCAmelCase  :							int				     =					resample if resample is not None else self.resample
														_lowerCAmelCase  :							List[Any]				     =					apply_ocr if apply_ocr is not None else self.apply_ocr
														_lowerCAmelCase  :							Tuple				     =					ocr_lang if ocr_lang is not None else self.ocr_lang
														_lowerCAmelCase  :							List[Any]				     =					tesseract_config if tesseract_config is not None else self.tesseract_config

														_lowerCAmelCase  :							Any				     =					make_list_of_images(__a)

														if not valid_images(__a):
																					raise ValueError(
																					    "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
																					    "torch.Tensor, tf.Tensor or jax.ndarray.")

														if do_resize and size is None:
																					raise ValueError("Size must be specified if do_resize is True.")

														# All transformations expect numpy arrays.
														_lowerCAmelCase  :							Dict				     =					[to_numpy_array(__a) for image in images]

														if apply_ocr:
																					requires_backends(self,    "pytesseract")
																					_lowerCAmelCase  :							List[Any]				     =					[]
																					_lowerCAmelCase  :							Optional[Any]				     =					[]
																					for image in images:
																												_lowerCAmelCase     ,					_lowerCAmelCase  :							Tuple				     =					apply_tesseract(__a,    __a,    __a)
																												words_batch.append(__a)
																												boxes_batch.append(__a)

														if do_resize:
																					_lowerCAmelCase  :							Any				     =					[self.resize(image=__a,    size=__a,    resample=__a) for image in images]

														# flip color channels from RGB to BGR (as Detectron2 requires this)
														_lowerCAmelCase  :							Dict				     =					[flip_channel_order(__a) for image in images]
														_lowerCAmelCase  :							List[Any]				     =					[to_channel_dimension_format(__a,    __a) for image in images]

														_lowerCAmelCase  :							Optional[Any]				     =					BatchFeature(data={"pixel_values": images},    tensor_type=__a)

														if apply_ocr:
																					_lowerCAmelCase  :							str				     =					words_batch
																					_lowerCAmelCase  :							List[Any]				     =					boxes_batch
														return data





def        A       (      _lowerCamelCase = 1_000_000						):





							'''simple docstring'''




							_lowerCAmelCase  :							Any				     =					1
							_lowerCAmelCase  :							Optional[Any]				     =					1
							_lowerCAmelCase  :							List[str]				     =					{1: 1}

							for inputa in range(2       ,				_lowerCamelCase						):
														_lowerCAmelCase  :							int				     =					0
														_lowerCAmelCase  :							Any				     =					inputa

														while True:
																					if number in counters:
																												counter += counters[number]
																												break
																					if number % 2 == 0:
																												number //= 2
																												counter += 1
																					else:
																												_lowerCAmelCase  :							Any				     =					(3 * number) + 1
																												counter += 1

														if inputa not in counters:
																					_lowerCAmelCase  :							Tuple				     =					counter

														if counter > pre_counter:
																					_lowerCAmelCase  :							Union[str, Any]				     =					inputa
																					_lowerCAmelCase  :							Union[str, Any]				     =					counter
							return largest_number


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