






"""simple docstring"""
import math

import torch
from torch import nn
from torch.nn import init

from .binarizer import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer



class 		a_      (	nn.Linear ):







      '''simple docstring'''

      def __init__(self,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_ = True,     lowerCamelCase_ = "constant",     lowerCamelCase_ = 0.0,     lowerCamelCase_ = "topK",     ):

       '''simple docstring'''



       super(lowerCamelCase_,     self					).__init__(in_features=lowerCamelCase_,     out_features=lowerCamelCase_,     bias=lowerCamelCase_					)
       assert pruning_method in ["topK", "threshold", "sigmoied_threshold", "magnitude", "l0"]
       lowerCamelCase__     :			Union[str, Any]     				=						pruning_method

       if self.pruning_method in ["topK", "threshold", "sigmoied_threshold", "l0"]:
        lowerCamelCase__     :			str     				=						mask_scale
        lowerCamelCase__     :			List[str]     				=						mask_init
        lowerCamelCase__     :			Any     				=						nn.Parameter(torch.empty(self.weight.size()					)					)
        self.init_mask()




      def 			a__							(self					):

       '''simple docstring'''



       if self.mask_init == "constant":
        init.constant_(self.mask_scores,     val=self.mask_scale					)
       elif self.mask_init == "uniform":
        init.uniform_(self.mask_scores,     a=-self.mask_scale,     b=self.mask_scale					)
       elif self.mask_init == "kaiming":
        init.kaiming_uniform_(self.mask_scores,     a=math.sqrt(5					)					)





      def 			a__							(self,     lowerCamelCase_,     lowerCamelCase_					):

       '''simple docstring'''



       if self.pruning_method == "topK":
        lowerCamelCase__     :			int     				=						TopKBinarizer.apply(self.mask_scores,     lowerCamelCase_					)
       elif self.pruning_method in ["threshold", "sigmoied_threshold"]:
        lowerCamelCase__     :			str     				=						'sigmoied' in self.pruning_method
        lowerCamelCase__     :			int     				=						ThresholdBinarizer.apply(self.mask_scores,     lowerCamelCase_,     lowerCamelCase_					)
       elif self.pruning_method == "magnitude":
        lowerCamelCase__     :			int     				=						MagnitudeBinarizer.apply(self.weight,     lowerCamelCase_					)
       elif self.pruning_method == "l0":
        lowerCamelCase__				,     lowerCamelCase__				,     lowerCamelCase__     :			str     				=						-0.1, 1.1, 2 / 3
        if self.training:
         lowerCamelCase__     :			int     				=						torch.zeros_like(self.mask_scores					).uniform_().clamp(0.0_001,     0.9_999					)
         lowerCamelCase__     :			Any     				=						torch.sigmoid((u.log() - (1 - u).log() + self.mask_scores) / b					)
        else:
         lowerCamelCase__     :			List[Any]     				=						torch.sigmoid(self.mask_scores					)
        lowerCamelCase__     :			Tuple     				=						s * (r - l) + l
        lowerCamelCase__     :			List[str]     				=						s_bar.clamp(min=0.0,     max=1.0					)
       # Mask weights with computed mask
       lowerCamelCase__     :			List[str]     				=						mask * self.weight
       # Compute output (linear layer) with masked weights
       return nn.functional.linear(lowerCamelCase_,     lowerCamelCase_,     self.bias					)







'''simple docstring'''







from __future__ import annotations

_lowerCamelCase							:						Union[str, Any]								=  {1: 1}






def 		_lowercase		(	lowercase_  ):



		'''simple docstring'''







		if n in COLLATZ_SEQUENCE_LENGTHS:
				return COLLATZ_SEQUENCE_LENGTHS[n]
		_snake_case	       =       n // 2 if n % 2 == 0 else 3 * n + 1
		_snake_case	       =       collatz_sequence_length(lowercase_  ) + 1
		_snake_case	       =       sequence_length
		return sequence_length






def 		_lowercase		(	lowercase_ = 1000000  ):



		'''simple docstring'''







		_snake_case	       =       max((collatz_sequence_length(lowercase_  ), i) for i in range(1						,							lowercase_  )  )
		return result[1]


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





