


import argparse
import os

import torch

from transformers import FlavaImageCodebook, FlavaImageCodebookConfig




def  a   (lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__   ):
   __a					=  s.rsplit(lowerCAmelCase__		,				lowerCAmelCase__   )
   return new.join(lowerCAmelCase__   )




def  a   (lowerCAmelCase__   ):
   # encoder.embeddings are double copied in original FLAVA
   return sum(param.float().sum() if """encoder.embeddings""" not in key else 0 for key, param in state_dict.items()   )




def  a   (lowerCAmelCase__   ):
   __a					=  {}

   __a					=  ["""group_1""", """group_2""", """group_3""", """group_4"""]
   for key, value in state_dict.items():
      for group_key in group_keys:
         if group_key in key:
            __a					=  key.replace(f'''{group_key}.'''		,				f'''{group_key}.group.'''   )

      if "res_path" in key:
         __a					=  key.replace("""res_path."""		,				"""res_path.path."""   )

      if key.endswith(""".w"""   ):
         __a					=  rreplace(lowerCAmelCase__		,				""".w"""		,				""".weight"""		,				1   )
      if key.endswith(""".b"""   ):
         __a					=  rreplace(lowerCAmelCase__		,				""".b"""		,				""".bias"""		,				1   )

      __a					=  value.float()

   return upgrade




@torch.no_grad()
def  a   (lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__=None		,				lowerCAmelCase__=True   ):
   from dall_e import Encoder

   __a					=  Encoder()
   if os.path.exists(lowerCAmelCase__   ):
      __a					=  torch.load(lowerCAmelCase__   )
   else:
      __a					=  torch.hub.load_state_dict_from_url(lowerCAmelCase__   )

   if isinstance(lowerCAmelCase__		,				lowerCAmelCase__   ):
      __a					=  ckpt.state_dict()
   encoder.load_state_dict(lowerCAmelCase__   )

   if config_path is not None:
      __a					=  FlavaImageCodebookConfig.from_pretrained(lowerCAmelCase__   )
   else:
      __a					=  FlavaImageCodebookConfig()

   __a					=  FlavaImageCodebook(lowerCAmelCase__   ).eval()
   __a					=  encoder.state_dict()

   __a					=  upgrade_state_dict(lowerCAmelCase__   )
   hf_model.load_state_dict(lowerCAmelCase__   )
   __a					=  hf_model.state_dict()
   __a					=  count_parameters(lowerCAmelCase__   )
   __a					=  count_parameters(lowerCAmelCase__   )

   assert torch.allclose(lowerCAmelCase__		,				lowerCAmelCase__		,				atol=1E-3   )

   if save_checkpoint:
      hf_model.save_pretrained(lowerCAmelCase__   )
   else:
      return hf_state_dict


if __name__ == "__main__":
  SCREAMING_SNAKE_CASE							    =							argparse.ArgumentParser()
  parser.add_argument('--pytorch_dump_folder_path', default=None, type=str, help='Path to the output PyTorch model.')
  parser.add_argument('--checkpoint_path', default=None, type=str, help='Path to flava checkpoint')
  parser.add_argument('--config_path', default=None, type=str, help='Path to hf config.json of model to convert')
  SCREAMING_SNAKE_CASE							    =							parser.parse_args()

  convert_dalle_checkpoint(args.checkpoint_path, args.pytorch_dump_folder_path, args.config_path)







def  a   (lowerCAmelCase__ = 1_000_000   ):
   __a					=  1
   __a					=  1
   __a					=  {1: 1}

   for inputa in range(2		,				lowerCAmelCase__   ):
      __a					=  0
      __a					=  inputa

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

      if inputa not in counters:
         __a					=  counter

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


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



