






import json
import os
import tempfile
import unittest
import unittest.mock as mock
from pathlib import Path

from requests.exceptions import HTTPError

from transformers.utils import (
    CONFIG_NAME,
    FLAX_WEIGHTS_NAME,
    TF2_WEIGHTS_NAME,
    TRANSFORMERS_CACHE,
    WEIGHTS_NAME,
    cached_file,
    get_file_from_repo,
    has_file,
)


__A      =				'hf-internal-testing/tiny-random-bert'
__A      =				os.path.join(TRANSFORMERS_CACHE, 'models--hf-internal-testing--tiny-random-bert')
__A      =				'9b8c223d42b2188cb49d29af482996f9d0f3e5a6'





class 						SCREAMING_SNAKE_CASE				( unittest.TestCase					):





							"""simple docstring"""

							def       __A (  self:   Union[str, Any]   )    ->				Optional[Any]:
												_A								= cached_file(__A		,     __A   )
												# Should have downloaded the file in here
												self.assertTrue(os.path.isdir(__A   )   )
												# Cache should contain at least those three subfolders:
												for subfolder in ["blobs", "refs", "snapshots"]:
																	self.assertTrue(os.path.isdir(os.path.join(__A		,     __A   )   )   )
												with open(os.path.join(__A		,     '''refs'''		,     '''main'''   )   ) as f:
																	_A								= f.read()
												self.assertEqual(__A		,     os.path.join(__A		,     '''snapshots'''		,     __A		,     __A   )   )
												self.assertTrue(os.path.isfile(__A   )   )

												# File is cached at the same place the second time.
												_A								= cached_file(__A		,     __A   )
												self.assertEqual(__A		,     __A   )

												# Using a specific revision to test the full commit hash.
												_A								= cached_file(__A		,     __A		,     revision='''9b8c223'''   )
												self.assertEqual(__A		,     os.path.join(__A		,     '''snapshots'''		,     __A		,     __A   )   )

							def       __A (  self:   Optional[Any]   )    ->				Dict:
												with self.assertRaisesRegex(__A		,     '''is not a valid model identifier'''   ):
																	_A								= cached_file('''tiny-random-bert'''		,     __A   )

												with self.assertRaisesRegex(__A		,     '''is not a valid git identifier'''   ):
																	_A								= cached_file(__A		,     __A		,     revision='''aaaa'''   )

												with self.assertRaisesRegex(__A		,     '''does not appear to have a file named'''   ):
																	_A								= cached_file(__A		,     '''conf'''   )

							def       __A (  self:   Dict   )    ->				List[str]:
												with self.assertRaisesRegex(__A		,     '''does not appear to have a file named'''   ):
																	_A								= cached_file(__A		,     '''conf'''   )

												with open(os.path.join(__A		,     '''refs'''		,     '''main'''   )   ) as f:
																	_A								= f.read()
												self.assertTrue(os.path.isfile(os.path.join(__A		,     '''.no_exist'''		,     __A		,     '''conf'''   )   )   )

												_A								= cached_file(__A		,     '''conf'''		,     _raise_exceptions_for_missing_entries=__A   )
												self.assertIsNone(__A   )

												_A								= cached_file(__A		,     '''conf'''		,     local_files_only=__A		,     _raise_exceptions_for_missing_entries=__A   )
												self.assertIsNone(__A   )

												_A								= mock.Mock()
												_A								= 5_00
												_A								= {}
												_A								= HTTPError
												_A								= {}

												# Under the mock environment we get a 500 error when trying to reach the tokenizer.
												with mock.patch('''requests.Session.request'''		,     return_value=__A   ) as mock_head:
																	_A								= cached_file(__A		,     '''conf'''		,     _raise_exceptions_for_connection_errors=__A   )
																	self.assertIsNone(__A   )
																	# This check we did call the fake head request
																	mock_head.assert_called()

							def       __A (  self:   Optional[Any]   )    ->				Dict:
												self.assertTrue(has_file('''hf-internal-testing/tiny-bert-pt-only'''		,     __A   )   )
												self.assertFalse(has_file('''hf-internal-testing/tiny-bert-pt-only'''		,     __A   )   )
												self.assertFalse(has_file('''hf-internal-testing/tiny-bert-pt-only'''		,     __A   )   )

							def       __A (  self:   Tuple   )    ->				Tuple:
												# `get_file_from_repo` returns None if the file does not exist
												self.assertIsNone(get_file_from_repo('''bert-base-cased'''		,     '''ahah.txt'''   )   )

												# The function raises if the repository does not exist.
												with self.assertRaisesRegex(__A		,     '''is not a valid model identifier'''   ):
																	get_file_from_repo('''bert-base-case'''		,     __A   )

												# The function raises if the revision does not exist.
												with self.assertRaisesRegex(__A		,     '''is not a valid git identifier'''   ):
																	get_file_from_repo('''bert-base-cased'''		,     __A		,     revision='''ahaha'''   )

												_A								= get_file_from_repo('''bert-base-cased'''		,     __A   )
												# The name is the cached name which is not very easy to test, so instead we load the content.
												_A								= json.loads(open(__A		,     '''r'''   ).read()   )
												self.assertEqual(config['''hidden_size''']		,     7_68   )



							def       __A (  self:   str   )    ->				Tuple:
												with tempfile.TemporaryDirectory() as tmp_dir:
																	_A								= Path(__A   ) / '''a.txt'''
																	filename.touch()
																	self.assertEqual(get_file_from_repo(__A		,     '''a.txt'''   )		,     str(__A   )   )

																	self.assertIsNone(get_file_from_repo(__A		,     '''b.txt'''   )   )











def      __A					(     _lowercase = 1_00_00_00 ):

					'''simple docstring'''







					_A								= 1
					_A								= 1
					_A								= {1: 1}

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



