




'''simple docstring'''
from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
A							:      Any 	=       [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
def 				snake_case_  (   a__		:	int			):



    """simple docstring"""




    return [int(a__			) for c in f'{ruleset:08}'[:8]]
def 				snake_case_  (   a__		:	list[list[int]]    ,a__		:	list[int]    ,a__		:	int			):



    """simple docstring"""




    __lowercase							=						len(cells[0]			)  # 31
    __lowercase							=						[]
    for i in range(a__			):
        # Get the neighbors of each cell
        # Handle neighbours outside bounds by using 0 as their value
        __lowercase							=						0 if i == 0 else cells[time][i - 1]
        __lowercase							=						0 if i == population - 1 else cells[time][i + 1]
        # Define a new cell and add it to the new generation
        __lowercase							=						7 - int(f'{left_neighbor}{cells[time][i]}{right_neighbor}'    ,2			)
        next_generation.append(rule[situation]			)
    return next_generation
def 				snake_case_  (   a__		:	list[list[int]]			):



    """simple docstring"""




    __lowercase							=						Image.new("""RGB"""    ,(len(cells[0]			), len(a__			))			)
    __lowercase							=						img.load()
    # Generates image
    for w in range(img.width			):
        for h in range(img.height			):
            __lowercase							=						2_55 - int(2_55 * cells[h][w]			)
            __lowercase							=						(color, color, color)
    return img


if __name__ == "__main__":
  A							:      Dict 	=       bin(int(input("""Rule:\n""").strip()))[2:]
  A							:      Union[str, Any] 	=       format_ruleset(int(rule_num))
  for time in range(16):
    CELLS.append(new_generation(CELLS, rule, time))
  A							:      Tuple 	=       generate_image(CELLS)
  # Uncomment to save the image
  # img.save(f"rule_{rule_num}.png")
  img.show()










'''simple docstring'''
from __future__ import annotations

A							:      List[str] 	=       {1: 1}
def 				snake_case_  (   a__		:	int			):



    """simple docstring"""




    if n in COLLATZ_SEQUENCE_LENGTHS:
        return COLLATZ_SEQUENCE_LENGTHS[n]
    __lowercase							=						n // 2 if n % 2 == 0 else 3 * n + 1
    __lowercase							=						collatz_sequence_length(a__			) + 1
    __lowercase							=						sequence_length
    return sequence_length
def 				snake_case_  (   a__		:	int = 1_00_00_00			):



    """simple docstring"""




    __lowercase							=						max((collatz_sequence_length(a__			), i) for i in range(1    ,a__			)			)
    return result[1]


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




