import math def main(): N = int(input()) n = int(math.sqrt(N)) for i in range(3, n + 1): if not N % i: break else: if N % 2: i = N else: i = max(4, N // 2) print(i) main()