import sys
x=int(input())
for i in range(3,1000010):
    if x%i==0:
        print(i)
        sys.exit(0)
print(x)