

import inspect
from typing import List, Optional, Tuple, Union

import torch

from ...models import UNetaDModel, VQModel
from ...schedulers import DDIMScheduler
from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput





class  __lowerCAmelCase     (					SCREAMING_SNAKE_CASE							):




  def __init__(				self							,   lowerCAmelCase							,   lowerCAmelCase							,   lowerCAmelCase					)  -> Any:
        '''simple docstring'''






        super().__init__()
        self.register_modules(vqvae=lowerCAmelCase							,   unet=lowerCAmelCase							,   scheduler=lowerCAmelCase					)




  @torch.no_grad()
  def __call__(				self							,   lowerCAmelCase = 1							,   lowerCAmelCase = None							,   lowerCAmelCase = 0.0							,   lowerCAmelCase = 50							,   lowerCAmelCase = "pil"							,   lowerCAmelCase = True							,   **lowerCAmelCase							,   )  -> Union[Tuple, ImagePipelineOutput]:
        '''simple docstring'''






        _lowercase	       =randn_tensor(
            (batch_size, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)							,   generator=lowerCAmelCase							,   )
        _lowercase	       =latents.to(self.device					)

        # scale the initial noise by the standard deviation required by the scheduler
        _lowercase	       =latents * self.scheduler.init_noise_sigma

        self.scheduler.set_timesteps(lowerCAmelCase					)

        # prepare extra kwargs for the scheduler step, since not all schedulers have the same signature
        _lowercase	       ='eta' in set(inspect.signature(self.scheduler.step					).parameters.keys()					)

        _lowercase	       ={}
        if accepts_eta:
              _lowercase	       =eta

        for t in self.progress_bar(self.scheduler.timesteps					):
              _lowercase	       =self.scheduler.scale_model_input(lowerCAmelCase							,   lowerCAmelCase					)
              # predict the noise residual
              _lowercase	       =self.unet(lowerCAmelCase							,   lowerCAmelCase					).sample
              # compute the previous noisy sample x_t -> x_t-1
              _lowercase	       =self.scheduler.step(lowerCAmelCase							,   lowerCAmelCase							,   lowerCAmelCase							,   **lowerCAmelCase					).prev_sample

        # decode the image latents with the VAE
        _lowercase	       =self.vqvae.decode(lowerCAmelCase					).sample

        _lowercase	       =(image / 2 + 0.5).clamp(0							,   1					)
        _lowercase	       =image.cpu().permute(0							,   2							,   3							,   1					).numpy()
        if output_type == "pil":
              _lowercase	       =self.numpy_to_pil(lowerCAmelCase					)

        if not return_dict:
              return (image,)

        return ImagePipelineOutput(images=lowerCAmelCase					)





def      a      (			A__	:   int = 1000000     )    ->      int:





      """simple docstring"""



      _lowercase	       =1
      _lowercase	       =1
      _lowercase	       ={1: 1}

      for inputa in range(2      ,   A__     ):
            _lowercase	       =0
            _lowercase	       =inputa

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

            if inputa not in counters:
                  _lowercase	       =counter

            if counter > pre_counter:
                  _lowercase	       =inputa
                  _lowercase	       =counter
      return largest_number


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


