


'''simple docstring'''







from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments
from transformers.testing_utils import TestCasePlus, require_torch, slow
from transformers.utils import is_datasets_available


if is_datasets_available():
 import datasets


class  lowerCAmelCase_						(       lowerCAmelCase__      ):





  """simple docstring"""



  @slow
  @require_torch
  def __a						(					self     :							Union[str, Any]						):





       '''simple docstring'''

       __a       =   EncoderDecoderModel.from_encoder_decoder_pretrained("""prajjwal1/bert-tiny"""				,							"""prajjwal1/bert-tiny"""						)
       __a       =   BertTokenizer.from_pretrained("""bert-base-uncased"""						)

       __a       =   bertabert.config.encoder.vocab_size
       __a       =   tokenizer.sep_token_id
       __a       =   tokenizer.cls_token_id
       __a       =   1_2_8

       __a       =   datasets.load_dataset("""cnn_dailymail"""				,							"""3.0.0"""				,							split="""train[:1%]"""						)
       __a       =   datasets.load_dataset("""cnn_dailymail"""				,							"""3.0.0"""				,							split="""validation[:1%]"""						)

       __a       =   train_dataset.select(range(3_2						)						)
       __a       =   val_dataset.select(range(1_6						)						)

       __a       =   4

       def _map_to_encoder_decoder_inputs(SCREAMING_SNAKE_CASE__     :							Optional[Any]						):
            # Tokenizer will automatically set [BOS] <text> [EOS]
            __a       =   tokenizer(batch["""article"""]				,							padding="""max_length"""				,							truncation=_SCREAMING_SNAKE_CASE				,							max_length=5_1_2						)
            __a       =   tokenizer(batch["""highlights"""]				,							padding="""max_length"""				,							truncation=_SCREAMING_SNAKE_CASE				,							max_length=1_2_8						)
            __a       =   inputs.input_ids
            __a       =   inputs.attention_mask

            __a       =   outputs.input_ids
            __a       =   outputs.input_ids.copy()
            __a       =   [
                [-1_0_0 if token == tokenizer.pad_token_id else token for token in labels] for labels in batch["""labels"""]
            ]
            __a       =   outputs.attention_mask

            assert all(len(_SCREAMING_SNAKE_CASE						) == 5_1_2 for x in inputs.input_ids						)
            assert all(len(_SCREAMING_SNAKE_CASE						) == 1_2_8 for x in outputs.input_ids						)

            return batch

       def _compute_metrics(SCREAMING_SNAKE_CASE__     :							List[Any]						):
            __a       =   pred.label_ids
            __a       =   pred.predictions

            # all unnecessary tokens are removed
            __a       =   tokenizer.batch_decode(_SCREAMING_SNAKE_CASE				,							skip_special_tokens=_SCREAMING_SNAKE_CASE						)
            __a       =   tokenizer.batch_decode(_SCREAMING_SNAKE_CASE				,							skip_special_tokens=_SCREAMING_SNAKE_CASE						)

            __a       =   sum([int(pred_str[i] == label_str[i]						) for i in range(len(_SCREAMING_SNAKE_CASE						)						)]						) / len(_SCREAMING_SNAKE_CASE						)

            return {"accuracy": accuracy}

       # map train dataset
       __a       =   train_dataset.map(
           _map_to_encoder_decoder_inputs				,							batched=_SCREAMING_SNAKE_CASE				,							batch_size=_SCREAMING_SNAKE_CASE				,							remove_columns=["""article""", """highlights"""]				,							)
       train_dataset.set_format(
           type="""torch"""				,							columns=["""input_ids""", """attention_mask""", """decoder_input_ids""", """decoder_attention_mask""", """labels"""]				,							)

       # same for validation dataset
       __a       =   val_dataset.map(
           _map_to_encoder_decoder_inputs				,							batched=_SCREAMING_SNAKE_CASE				,							batch_size=_SCREAMING_SNAKE_CASE				,							remove_columns=["""article""", """highlights"""]				,							)
       val_dataset.set_format(
           type="""torch"""				,							columns=["""input_ids""", """attention_mask""", """decoder_input_ids""", """decoder_attention_mask""", """labels"""]				,							)

       __a       =   self.get_auto_remove_tmp_dir()

       __a       =   SeqaSeqTrainingArguments(
           output_dir=_SCREAMING_SNAKE_CASE				,							per_device_train_batch_size=_SCREAMING_SNAKE_CASE				,							per_device_eval_batch_size=_SCREAMING_SNAKE_CASE				,							predict_with_generate=_SCREAMING_SNAKE_CASE				,							evaluation_strategy="""steps"""				,							do_train=_SCREAMING_SNAKE_CASE				,							do_eval=_SCREAMING_SNAKE_CASE				,							warmup_steps=0				,							eval_steps=2				,							logging_steps=2				,							)

       # instantiate trainer
       __a       =   SeqaSeqTrainer(
           model=_SCREAMING_SNAKE_CASE				,							args=_SCREAMING_SNAKE_CASE				,							compute_metrics=_compute_metrics				,							train_dataset=_SCREAMING_SNAKE_CASE				,							eval_dataset=_SCREAMING_SNAKE_CASE				,							tokenizer=_SCREAMING_SNAKE_CASE				,							)

       # start training
       trainer.train()










'''simple docstring'''







def        __lowercase						(      __SCREAMING_SNAKE_CASE = 100_0000		)				->					int:
     """simple docstring"""




     __a       =   1
     __a       =   1
     __a       =   {1: 1}

     for inputa in range(2				,  __SCREAMING_SNAKE_CASE		):
          __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())))






