





"""simple docstring"""




from __future__ import annotations

from collections.abc import Generator



def 					a__				(       )		->      Generator[int, None, None]:
			lowerCamelCase       =      {}
			lowerCamelCase       =      2
			while True:
						lowerCamelCase       =      factor_map.pop(snake_case__ ,				snake_case__       )
						if factor:
									lowerCamelCase       =      factor + prime
									while x in factor_map:
												x += factor
									lowerCamelCase       =      factor
						else:
									lowerCamelCase       =      prime
									yield prime
						prime += 1



def 					a__				(       snake_case__ = 1E10       )		->      int:
			lowerCamelCase       =      sieve()

			lowerCamelCase       =      1
			while True:
						lowerCamelCase       =      next(snake_case__       )
						if (2 * prime * n) > limit:
									return n
						# Ignore the next prime as the reminder will be 2.
						next(snake_case__       )
						n += 2


if __name__ == "__main__":
					print(solution())









"""simple docstring"""




def 					a__				(       snake_case__ = 1_00_00_00       )		->      int:
			lowerCamelCase       =      1
			lowerCamelCase       =      1
			lowerCamelCase       =      {1: 1}

			for inputa in range(2 ,				snake_case__       ):
						lowerCamelCase       =      0
						lowerCamelCase       =      inputa

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

						if inputa not in counters:
									lowerCamelCase       =      counter

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


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



