import math

N = input()
n = N
cnt = 0
while n % 2 == 0:
    n /= 2
    cnt += 1
if n % 3 == 0:
    print 3
elif cnt >= 2:
    print 4
else:
    SQRT_N = int(math.floor(math.sqrt(N)))
    flag = False
    for i in xrange(3, SQRT_N +1, 2):
        if N % i == 0:
            flag = True
            break
    if flag:
        print i
    else:
        print n