import random as s def p(q,k=1000): if q%2==0:return 0 d=(q-1)>>1 while d&1==0:d>>=1 while k: k-=1 t=d y=pow(s.randint(1,q-1),t,q) while t!=q-1 and y!=1 and y!=q-1: y=pow(y,2,q) t<<=1 if y!=q-1 and t&1==0:return 0 return 1 n=int(input()) if p(n): print(n) elif p(n//2): print(n//2) else: if n%4==0: print(4) else: for i in range(3,n+3,2): if n%i==0: print(i) break else:print(n)