N = input() n = N if n % 3 == 0: print 3 else: cnt = 0 while n % 2 == 0: n /= 2 cnt += 1 if cnt >= 2: print 4 else: flag = False for i in xrange(3, int(N**0.5)+1, 2): if N % i == 0: flag = True break if flag: print i else: print n