x = input() ans = x/2 if x!=4 and x%2==0 else x for i in xrange(3,2000000): if x%i==0: ans = min(ans,i) print ans