n = int(raw_input())
vis = [False for_ in xrange(n+1)]
p, q = [], []
for i in xrange(2, n+1):
   if vis[i]:
       continue
   p.append(i)
   for j in xrange(i+i, n+1, i):
       vis[j]=True
for i in p:
   cc, tmp=1, i
   while tmp <= n:
       cc += 1
       tmp *= i
   q.append(cc-1)
lb, ub = n, n*n
while ub - lb > 1:
   mid = (lb + ub) / 2
   flag = True
 
   for (i, j) in zip(p, q):
       if mid < 2 * (i**j):
           flag = False
           break
   if flag:
       ub = mid
   else:
       lb = mid
print ub