# -*- coding: utf-8 -*- N = int(input()) i = 3 is_prime = True while i*i<=N: if N%i == 0: is_prime = False break i += 1 if is_prime: if N%2 == 0: if N//2==2: print(N) else: print(N//2) else: print(N) else: print(i)