

'''simple docstring'''



import inspect
import unittest

from huggingface_hub import hf_hub_download

from transformers import ASTConfig
from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_torchaudio_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch
		from torch import nn

		from transformers import ASTForAudioClassification, ASTModel
		from transformers.models.audio_spectrogram_transformer.modeling_audio_spectrogram_transformer import (
		    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
		)


if is_torchaudio_available():
		import torchaudio

		from transformers import ASTFeatureExtractor



class lowerCamelCase :



			'''simple docstring'''






			def __init__(      self       :						Any		,			lowerCAmelCase_       :						Union[str, Any]		,			lowerCAmelCase_       :						List[str]=13		,			lowerCAmelCase_       :						Union[str, Any]=2		,			lowerCAmelCase_       :						Dict=24		,			lowerCAmelCase_       :						Optional[Any]=16		,			lowerCAmelCase_       :						List[Any]=True		,			lowerCAmelCase_       :						Optional[Any]=True		,			lowerCAmelCase_       :						Any=32		,			lowerCAmelCase_       :						Tuple=5		,			lowerCAmelCase_       :						int=4		,			lowerCAmelCase_       :						Tuple=37		,			lowerCAmelCase_       :						List[str]="gelu"		,			lowerCAmelCase_       :						Tuple=0.1		,			lowerCAmelCase_       :						Any=0.1		,			lowerCAmelCase_       :						Optional[int]=10		,			lowerCAmelCase_       :						Any=0.02		,			lowerCAmelCase_       :						Union[str, Any]=None		,			lowerCAmelCase_       :						Union[str, Any]=2		,			lowerCAmelCase_       :						List[Any]=2		,			)			->		List[Any]:





									'''simple docstring'''
									A__     :   Union[str, Any]      =parent
									A__     :   Any      =batch_size
									A__     :   List[Any]      =patch_size
									A__     :   List[str]      =max_length
									A__     :   Optional[Any]      =num_mel_bins
									A__     :   Optional[int]      =is_training
									A__     :   Optional[int]      =use_labels
									A__     :   Dict      =hidden_size
									A__     :   Union[str, Any]      =num_hidden_layers
									A__     :   str      =num_attention_heads
									A__     :   List[str]      =intermediate_size
									A__     :   Union[str, Any]      =hidden_act
									A__     :   List[str]      =hidden_dropout_prob
									A__     :   Optional[int]      =attention_probs_dropout_prob
									A__     :   int      =type_sequence_label_size
									A__     :   int      =initializer_range
									A__     :   Union[str, Any]      =scope
									A__     :   str      =frequency_stride
									A__     :   Union[str, Any]      =time_stride

									# in AST, the seq length equals the number of patches + 2 (we add 2 for the [CLS] and distillation tokens)
									A__     :   Optional[Any]      =(self.num_mel_bins - self.patch_size) // self.frequency_stride + 1
									A__     :   Union[str, Any]      =(self.max_length - self.patch_size) // self.time_stride + 1
									A__     :   str      =frequency_out_dimension * time_out_dimension
									A__     :   str      =num_patches + 2


			def lowercase__						(      self       :						Optional[int] )			->		List[str]:





									'''simple docstring'''
									A__     :   Optional[int]      =floats_tensor([self.batch_size, self.max_length, self.num_mel_bins] )

									A__     :   List[Any]      =None
									if self.use_labels:
															A__     :   Optional[int]      =ids_tensor([self.batch_size]		,			self.type_sequence_label_size )

									A__     :   int      =self.get_config()

									return config, input_values, labels


			def lowercase__						(      self       :						Tuple )			->		Optional[Any]:





									'''simple docstring'''
									return ASTConfig(
									    patch_size=self.patch_size		,			max_length=self.max_length		,			num_mel_bins=self.num_mel_bins		,			hidden_size=self.hidden_size		,			num_hidden_layers=self.num_hidden_layers		,			num_attention_heads=self.num_attention_heads		,			intermediate_size=self.intermediate_size		,			hidden_act=self.hidden_act		,			hidden_dropout_prob=self.hidden_dropout_prob		,			attention_probs_dropout_prob=self.attention_probs_dropout_prob		,			is_decoder=UpperCamelCase__		,			initializer_range=self.initializer_range		,			frequency_stride=self.frequency_stride		,			time_stride=self.time_stride		,			)


			def lowercase__						(      self       :						int		,			lowerCAmelCase_       :						List[str]		,			lowerCAmelCase_       :						Optional[Any]		,			lowerCAmelCase_       :						int )			->		Dict:





									'''simple docstring'''
									A__     :   Union[str, Any]      =ASTModel(config=UpperCamelCase__ )
									model.to(UpperCamelCase__ )
									model.eval()
									A__     :   Optional[int]      =model(UpperCamelCase__ )
									self.parent.assertEqual(result.last_hidden_state.shape		,			(self.batch_size, self.seq_length, self.hidden_size) )



			def lowercase__						(      self       :						List[Any] )			->		Optional[Any]:





									'''simple docstring'''
									A__     :   int      =self.prepare_config_and_inputs()
									(
									    A__      
									)     :   int      =config_and_inputs
									A__     :   int      ={"input_values": input_values}
									return config, inputs_dict



@require_torch
class lowerCamelCase (  lowerCAmelCase__       ,						lowerCAmelCase__       ,						unittest.TestCase						):



			'''simple docstring'''






			__snake_case    	=       (
			    (
			        ASTModel,
			        ASTForAudioClassification,
			    )
			    if is_torch_available()
			    else ()
			)
			__snake_case    	=       (
			    {"""audio-classification""": ASTForAudioClassification, """feature-extraction""": ASTModel}
			    if is_torch_available()
			    else {}
			)
			__snake_case    	=       False
			__snake_case    	=       False
			__snake_case    	=       False
			__snake_case    	=       False


			def lowercase__						(      self       :						Optional[int]		,			lowerCAmelCase_       :						str		,			lowerCAmelCase_       :						int		,			lowerCAmelCase_       :						Dict		,			lowerCAmelCase_       :						List[str]		,			lowerCAmelCase_       :						Union[str, Any] )			->		List[Any]:





									'''simple docstring'''
									if pipeline_test_casse_name == "AudioClassificationPipelineTests":
															return True

									return False


			def lowercase__						(      self       :						List[Any] )			->		int:





									'''simple docstring'''
									A__     :   List[Any]      =ASTModelTester(self )
									A__     :   Any      =ConfigTester(self		,			config_class=UpperCamelCase__		,			has_text_modality=UpperCamelCase__		,			hidden_size=37 )


			def lowercase__						(      self       :						Any )			->		Union[str, Any]:





									'''simple docstring'''
									self.config_tester.run_common_tests()


			@unittest.skip(reason="""AST does not use inputs_embeds""" )
			def lowercase__						(      self       :						List[str] )			->		List[Any]:





									'''simple docstring'''
									pass


			def lowercase__						(      self       :						Union[str, Any] )			->		str:





									'''simple docstring'''
									A__     :   Dict      =self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
															A__     :   List[str]      =model_class(UpperCamelCase__ )
															self.assertIsInstance(model.get_input_embeddings()		,			(nn.Module) )
															A__     :   Optional[int]      =model.get_output_embeddings()
															self.assertTrue(x is None or isinstance(UpperCamelCase__		,			nn.Linear ) )


			def lowercase__						(      self       :						Dict )			->		Dict:





									'''simple docstring'''
									A__     :   Any      =self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
															A__     :   Dict      =model_class(UpperCamelCase__ )
															A__     :   List[Any]      =inspect.signature(model.forward )
															# signature.parameters is an OrderedDict => so arg_names order is deterministic
															A__     :   int      =[*signature.parameters.keys()]

															A__     :   Union[str, Any]      =["input_values"]
															self.assertListEqual(arg_names[:1]		,			UpperCamelCase__ )


			def lowercase__						(      self       :						List[Any] )			->		Union[str, Any]:





									'''simple docstring'''
									A__     :   List[Any]      =self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*UpperCamelCase__ )



			@slow
			def lowercase__						(      self       :						Any )			->		str:





									'''simple docstring'''
									for model_name in AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															A__     :   str      =ASTModel.from_pretrained(UpperCamelCase__ )
															self.assertIsNotNone(UpperCamelCase__ )


def 						__lowerCamelCase       (   )       ->							Optional[Any]:






						"""simple docstring"""





						A__     :   Union[str, Any]      =hf_hub_download(
						    repo_id="""nielsr/audio-spectogram-transformer-checkpoint""",		filename="""sample_audio.flac""",		repo_type="""dataset"""       )

						A__     :   List[str]      =torchaudio.load(_SCREAMING_SNAKE_CASE       )

						return audio, sampling_rate



@require_torch
@require_torchaudio
class lowerCamelCase (  unittest.TestCase						):



			'''simple docstring'''






			@cached_property
			def lowercase__						(      self       :						int )			->		List[Any]:





									'''simple docstring'''
									return (
									    ASTFeatureExtractor.from_pretrained("""MIT/ast-finetuned-audioset-10-10-0.4593""" )
									    if is_torchaudio_available()
									    else None
									)



			@slow
			def lowercase__						(      self       :						Dict )			->		Optional[int]:





									'''simple docstring'''
									A__     :   List[Any]      =self.default_feature_extractor
									A__     :   Dict      =ASTForAudioClassification.from_pretrained("""MIT/ast-finetuned-audioset-10-10-0.4593""" ).to(UpperCamelCase__ )

									A__     :   Dict      =self.default_feature_extractor
									A__     :   int      =prepare_audio()
									A__     :   Union[str, Any]      =audio.squeeze().numpy()
									A__     :   str      =feature_extractor(UpperCamelCase__		,			sampling_rate=UpperCamelCase__		,			return_tensors="""pt""" ).to(UpperCamelCase__ )

									# forward pass
									with torch.no_grad():
															A__     :   Any      =model(**UpperCamelCase__ )

									# verify the logits
									A__     :   List[str]      =torch.Size((1, 5_27) )
									self.assertEqual(outputs.logits.shape		,			UpperCamelCase__ )

									A__     :   List[Any]      =torch.tensor([-0.8760, -7.0042, -8.6602] ).to(UpperCamelCase__ )

									self.assertTrue(torch.allclose(outputs.logits[0, :3]		,			UpperCamelCase__		,			atol=1e-4 ) )







def      A      (      _SCREAMING_SNAKE_CASE = 100_0000    )	-> int:
       lowerCamelCase   :      Tuple			 =					1
       lowerCamelCase   :      int			 =					1
       lowerCamelCase   :      Optional[Any]			 =					{1: 1}

       for inputa in range(2 ,_SCREAMING_SNAKE_CASE    ):
              lowerCamelCase   :      Union[str, Any]			 =					0
              lowerCamelCase   :      List[str]			 =					inputa

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

              if inputa not in counters:
                     lowerCamelCase   :      str			 =					counter

              if counter > pre_counter:
                     lowerCamelCase   :      str			 =					inputa
                     lowerCamelCase   :      Any			 =					counter
       return largest_number


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






