




'''simple docstring'''







import torch

from diffusers import LMSDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest





class      lowerCamelCase_							(       UpperCAmelCase_							):




					'''simple docstring'''






					lowercase__    = (LMSDiscreteScheduler,)
					lowercase__    = 1_0






					def 				__SCREAMING_SNAKE_CASE	(    self,  **__UpperCamelCase ):
							_snake_case	       =       {
							    "num_train_timesteps": 1_100,
							    "beta_start": 0.00_01,
							    "beta_end": 0.02,
							    "beta_schedule": "linear",
							}

							config.update(**__UpperCamelCase )
							return config






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							for timesteps in [10, 50, 100, 1_000]:
									self.check_over_configs(num_train_timesteps=__UpperCamelCase )






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							for beta_start, beta_end in zip([0.0_00_01, 0.00_01, 0.0_01],  [0.00_02, 0.0_02, 0.02] ):
									self.check_over_configs(beta_start=__UpperCamelCase,  beta_end=__UpperCamelCase )






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							for schedule in ["linear", "scaled_linear"]:
									self.check_over_configs(beta_schedule=__UpperCamelCase )






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							for prediction_type in ["epsilon", "v_prediction"]:
									self.check_over_configs(prediction_type=__UpperCamelCase )






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							for t in [0, 500, 800]:
									self.check_over_forward(time_step=__UpperCamelCase )






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							_snake_case	       =       self.scheduler_classes[0]
							_snake_case	       =       self.get_scheduler_config()
							_snake_case	       =       scheduler_class(**__UpperCamelCase )

							scheduler.set_timesteps(self.num_inference_steps )

							_snake_case	       =       self.dummy_model()
							_snake_case	       =       self.dummy_sample_deter * scheduler.init_noise_sigma

							for i, t in enumerate(scheduler.timesteps ):
									_snake_case	       =       scheduler.scale_model_input(__UpperCamelCase,  __UpperCamelCase )

									_snake_case	       =       model(__UpperCamelCase,  __UpperCamelCase )

									_snake_case	       =       scheduler.step(__UpperCamelCase,  __UpperCamelCase,  __UpperCamelCase )
									_snake_case	       =       output.prev_sample

							_snake_case	       =       torch.sum(torch.abs(__UpperCamelCase ) )
							_snake_case	       =       torch.mean(torch.abs(__UpperCamelCase ) )

							assert abs(result_sum.item() - 10_06.3_88 ) < 1E-2
							assert abs(result_mean.item() - 1.31 ) < 1E-3






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							_snake_case	       =       self.scheduler_classes[0]
							_snake_case	       =       self.get_scheduler_config(prediction_type="v_prediction" )
							_snake_case	       =       scheduler_class(**__UpperCamelCase )

							scheduler.set_timesteps(self.num_inference_steps )

							_snake_case	       =       self.dummy_model()
							_snake_case	       =       self.dummy_sample_deter * scheduler.init_noise_sigma

							for i, t in enumerate(scheduler.timesteps ):
									_snake_case	       =       scheduler.scale_model_input(__UpperCamelCase,  __UpperCamelCase )

									_snake_case	       =       model(__UpperCamelCase,  __UpperCamelCase )

									_snake_case	       =       scheduler.step(__UpperCamelCase,  __UpperCamelCase,  __UpperCamelCase )
									_snake_case	       =       output.prev_sample

							_snake_case	       =       torch.sum(torch.abs(__UpperCamelCase ) )
							_snake_case	       =       torch.mean(torch.abs(__UpperCamelCase ) )

							assert abs(result_sum.item() - 0.00_17 ) < 1E-2
							assert abs(result_mean.item() - 2.2676E-06 ) < 1E-3






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							_snake_case	       =       self.scheduler_classes[0]
							_snake_case	       =       self.get_scheduler_config()
							_snake_case	       =       scheduler_class(**__UpperCamelCase )

							scheduler.set_timesteps(self.num_inference_steps,  device=__UpperCamelCase )

							_snake_case	       =       self.dummy_model()
							_snake_case	       =       self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
							_snake_case	       =       sample.to(__UpperCamelCase )

							for i, t in enumerate(scheduler.timesteps ):
									_snake_case	       =       scheduler.scale_model_input(__UpperCamelCase,  __UpperCamelCase )

									_snake_case	       =       model(__UpperCamelCase,  __UpperCamelCase )

									_snake_case	       =       scheduler.step(__UpperCamelCase,  __UpperCamelCase,  __UpperCamelCase )
									_snake_case	       =       output.prev_sample

							_snake_case	       =       torch.sum(torch.abs(__UpperCamelCase ) )
							_snake_case	       =       torch.mean(torch.abs(__UpperCamelCase ) )

							assert abs(result_sum.item() - 10_06.3_88 ) < 1E-2
							assert abs(result_mean.item() - 1.31 ) < 1E-3






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							_snake_case	       =       self.scheduler_classes[0]
							_snake_case	       =       self.get_scheduler_config()
							_snake_case	       =       scheduler_class(**__UpperCamelCase,  use_karras_sigmas=__UpperCamelCase )

							scheduler.set_timesteps(self.num_inference_steps,  device=__UpperCamelCase )

							_snake_case	       =       self.dummy_model()
							_snake_case	       =       self.dummy_sample_deter.to(__UpperCamelCase ) * scheduler.init_noise_sigma
							_snake_case	       =       sample.to(__UpperCamelCase )

							for t in scheduler.timesteps:
									_snake_case	       =       scheduler.scale_model_input(__UpperCamelCase,  __UpperCamelCase )

									_snake_case	       =       model(__UpperCamelCase,  __UpperCamelCase )

									_snake_case	       =       scheduler.step(__UpperCamelCase,  __UpperCamelCase,  __UpperCamelCase )
									_snake_case	       =       output.prev_sample

							_snake_case	       =       torch.sum(torch.abs(__UpperCamelCase ) )
							_snake_case	       =       torch.mean(torch.abs(__UpperCamelCase ) )

							assert abs(result_sum.item() - 38_12.99_27 ) < 2E-2
							assert abs(result_mean.item() - 4.96_48 ) < 1E-3











'''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())))





