

import math



class 						a_			:



      """simple docstring"""







      def __init__( self	:				Dict     ,snake_case	:				int     ,snake_case	:				int     ,snake_case	:				int     ,snake_case	:				Any							):
           SCREAMING_SNAKE_CASE 		=x
           SCREAMING_SNAKE_CASE 		=y
           SCREAMING_SNAKE_CASE 		=step_size
           SCREAMING_SNAKE_CASE 		=function_to_optimize
      def 			_lowerCAmelCase	( self	:				Dict							):
           return self.function(self.x     ,self.y							)
      def 			_lowerCAmelCase	( self	:				List[str]							):
           SCREAMING_SNAKE_CASE 		=self.step_size
           return [
               SearchProblem(snake_case     ,snake_case     ,snake_case     ,self.function							)
               for x, y in (
                   (self.x - step_size, self.y - step_size),
                   (self.x - step_size, self.y),
                   (self.x - step_size, self.y + step_size),
                   (self.x, self.y - step_size),
                   (self.x, self.y + step_size),
                   (self.x + step_size, self.y - step_size),
                   (self.x + step_size, self.y),
                   (self.x + step_size, self.y + step_size),
               )
           ]
      def __hash__( self	:				Any							):
           return hash(str(self							)							)
      def __eq__( self	:				str     ,snake_case	:				List[Any]							):
           if isinstance(snake_case     ,snake_case							):
                return hash(str(self							)							) == hash(str(snake_case							)							)
           return False


      def __str__( self	:				List[str]							):
           return f'x: {self.x} y: {self.y}'







def      snake_case__							(  lowerCAmelCase_,       lowerCAmelCase_ = True,       lowerCAmelCase_ = math.inf,       lowerCAmelCase_ = -math.inf,       lowerCAmelCase_ = math.inf,       lowerCAmelCase_ = -math.inf,       lowerCAmelCase_ = False,       lowerCAmelCase_ = 10000,       ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE 		=search_prob
     SCREAMING_SNAKE_CASE 		=[]  # list to store the current score at each iteration
     SCREAMING_SNAKE_CASE 		=0
     SCREAMING_SNAKE_CASE 		=False
     SCREAMING_SNAKE_CASE 		=set()
     while not solution_found and iterations < max_iter:
          visited.add(lowerCAmelCase_     )
          iterations += 1
          SCREAMING_SNAKE_CASE 		=current_state.score()
          scores.append(lowerCAmelCase_     )
          SCREAMING_SNAKE_CASE 		=current_state.get_neighbors()
          SCREAMING_SNAKE_CASE 		=-math.inf
          SCREAMING_SNAKE_CASE 		=math.inf
          SCREAMING_SNAKE_CASE 		=None  # to hold the next best neighbor
          for neighbor in neighbors:
               if neighbor in visited:
                    continue  # do not want to visit the same state again
               if (
                   neighbor.x > max_x
                   or neighbor.x < min_x
                   or neighbor.y > max_y
                   or neighbor.y < min_y
               ):
                    continue  # neighbor outside our bounds
               SCREAMING_SNAKE_CASE 		=neighbor.score() - current_score
               if find_max:  # finding max
                    # going to direction with greatest ascent
                    if change > max_change and change > 0:
                         SCREAMING_SNAKE_CASE 		=change
                         SCREAMING_SNAKE_CASE 		=neighbor
               else:  # finding min
                    # to direction with greatest descent
                    if change < min_change and change < 0:
                         SCREAMING_SNAKE_CASE 		=change
                         SCREAMING_SNAKE_CASE 		=neighbor
          if next_state is not None:
               # we found at least one neighbor which improved the current state
               SCREAMING_SNAKE_CASE 		=next_state
          else:
               # since we have no neighbor that improves the solution we stop the search
               SCREAMING_SNAKE_CASE 		=True

     if visualization:
          from matplotlib import pyplot as plt

          plt.plot(range(lowerCAmelCase_     ),       lowerCAmelCase_     )
          plt.xlabel('Iterations'     )
          plt.ylabel('Function values'     )
          plt.show()

     return current_state


if __name__ == "__main__":
 import doctest

 doctest.testmod()







 def      snake_case__							(  lowerCAmelCase_,       lowerCAmelCase_     ):





      """simple docstring"""







      return (x**2) + (y**2)

 # starting the problem with initial coordinates (3, 4)
 _lowerCamelCase							=SearchProblem(x=3, y=4, step_size=1, function_to_optimize=test_fa)
 _lowerCamelCase							=hill_climbing(prob, find_max=False)
 print(
     "The minimum score for f(x, y) = x^2 + y^2 found via hill climbing: "
     f'{local_min.score()}'
 )

 # starting the problem with initial coordinates (12, 47)
 _lowerCamelCase							=SearchProblem(x=12, y=47, step_size=1, function_to_optimize=test_fa)
 _lowerCamelCase							=hill_climbing(
     prob, find_max=False, max_x=1_00, min_x=5, max_y=50, min_y=-5, visualization=True
 )
 print(
     "The minimum score for f(x, y) = x^2 + y^2 with the domain 100 > x > 5 "
     f'and 50 > y > - 5 found via hill climbing: {local_min.score()}'
 )







 def      snake_case__							(  lowerCAmelCase_,       lowerCAmelCase_     ):





      """simple docstring"""







      return (3 * x**2) - (6 * y)

 _lowerCamelCase							=SearchProblem(x=3, y=4, step_size=1, function_to_optimize=test_fa)
 _lowerCamelCase							=hill_climbing(prob, find_max=True)



 print(
     "The maximum score for f(x, y) = x^2 + y^2 found via hill climbing: "
     f'{local_min.score()}'
 )




from __future__ import annotations

_lowerCamelCase							={1: 1}







def      snake_case__							(  lowerCAmelCase_     ):





     """simple docstring"""







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







def      snake_case__							(  lowerCAmelCase_ = 1000000     ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE 		=max((collatz_sequence_length(lowerCAmelCase_     ), i) for i in range(1,       lowerCAmelCase_     )     )
     return result[1]


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

