




'''simple docstring'''







import unittest

import numpy as np
import torch

from diffusers import DDPMPipeline, DDPMScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device


enable_full_determinism()





class      lowerCamelCase_							(       unittest.TestCase							):




					'''simple docstring'''






					@property
					def 				__SCREAMING_SNAKE_CASE	(    self ):
							torch.manual_seed(0 )
							_snake_case	       =       UNetaDModel(
							    block_out_channels=(32, 64),  layers_per_block=2,  sample_size=32,  in_channels=3,  out_channels=3,  down_block_types=("DownBlock2D", "AttnDownBlock2D"),  up_block_types=("AttnUpBlock2D", "UpBlock2D"),  )
							return model






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							_snake_case	       =       "cpu"
							_snake_case	       =       self.dummy_uncond_unet
							_snake_case	       =       DDPMScheduler()

							_snake_case	       =       DDPMPipeline(unet=__UpperCamelCase,  scheduler=__UpperCamelCase )
							ddpm.to(__UpperCamelCase )
							ddpm.set_progress_bar_config(disable=__UpperCamelCase )

							_snake_case	       =       torch.Generator(device=__UpperCamelCase ).manual_seed(0 )
							_snake_case	       =       ddpm(generator=__UpperCamelCase,  num_inference_steps=2,  output_type="numpy" ).images

							_snake_case	       =       torch.Generator(device=__UpperCamelCase ).manual_seed(0 )
							_snake_case	       =       ddpm(generator=__UpperCamelCase,  num_inference_steps=2,  output_type="numpy",  return_dict=__UpperCamelCase )[0]

							_snake_case	       =       image[0, -3:, -3:, -1]
							_snake_case	       =       image_from_tuple[0, -3:, -3:, -1]

							assert image.shape == (1, 32, 32, 3)
							_snake_case	       =       np.array(
							    [9.956E-01, 5.785E-01, 4.675E-01, 9.930E-01, 0.0, 1.0_00, 1.199E-03, 2.648E-04, 5.101E-04] )

							assert np.abs(image_slice.flatten() - expected_slice ).max() < 1E-2
							assert np.abs(image_from_tuple_slice.flatten() - expected_slice ).max() < 1E-2






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							_snake_case	       =       self.dummy_uncond_unet
							_snake_case	       =       DDPMScheduler(prediction_type="sample" )

							_snake_case	       =       DDPMPipeline(unet=__UpperCamelCase,  scheduler=__UpperCamelCase )
							ddpm.to(__UpperCamelCase )
							ddpm.set_progress_bar_config(disable=__UpperCamelCase )

							_snake_case	       =       torch.manual_seed(0 )
							_snake_case	       =       ddpm(generator=__UpperCamelCase,  num_inference_steps=2,  output_type="numpy" ).images

							_snake_case	       =       torch.manual_seed(0 )
							_snake_case	       =       ddpm(generator=__UpperCamelCase,  num_inference_steps=2,  output_type="numpy" )[0]

							_snake_case	       =       image[0, -3:, -3:, -1]
							_snake_case	       =       image_eps[0, -3:, -3:, -1]

							assert image.shape == (1, 32, 32, 3)
							_snake_case	       =       1E-2 if torch_device != "mps" else 3E-2
							assert np.abs(image_slice.flatten() - image_eps_slice.flatten() ).max() < tolerance





@slow
@require_torch_gpu
class      lowerCamelCase_							(       unittest.TestCase							):




					'''simple docstring'''






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							_snake_case	       =       "google/ddpm-cifar10-32"

							_snake_case	       =       UNetaDModel.from_pretrained(__UpperCamelCase )
							_snake_case	       =       DDPMScheduler.from_pretrained(__UpperCamelCase )

							_snake_case	       =       DDPMPipeline(unet=__UpperCamelCase,  scheduler=__UpperCamelCase )
							ddpm.to(__UpperCamelCase )
							ddpm.set_progress_bar_config(disable=__UpperCamelCase )

							_snake_case	       =       torch.manual_seed(0 )
							_snake_case	       =       ddpm(generator=__UpperCamelCase,  output_type="numpy" ).images

							_snake_case	       =       image[0, -3:, -3:, -1]

							assert image.shape == (1, 32, 32, 3)
							_snake_case	       =       np.array([0.42_00, 0.35_88, 0.19_39, 0.38_47, 0.33_82, 0.26_47, 0.41_55, 0.35_82, 0.33_85] )
							assert np.abs(image_slice.flatten() - expected_slice ).max() < 1E-2











'''simple docstring'''







from __future__ import annotations

_lowerCamelCase							:						Union[str, Any]								=  {1: 1}






def 		_lowercase		(	lowercase_  ):



		'''simple docstring'''







		if n in COLLATZ_SEQUENCE_LENGTHS:
				return COLLATZ_SEQUENCE_LENGTHS[n]
		_snake_case	       =       n // 2 if n % 2 == 0 else 3 * n + 1
		_snake_case	       =       collatz_sequence_length(lowercase_  ) + 1
		_snake_case	       =       sequence_length
		return sequence_length






def 		_lowercase		(	lowercase_ = 1000000  ):



		'''simple docstring'''







		_snake_case	       =       max((collatz_sequence_length(lowercase_  ), i) for i in range(1						,							lowercase_  )  )
		return result[1]


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





