import math
from collections import Counter


def how_many(n: int, p: int) -> int:
    ans = 0
    while n % p == 0:
        ans += 1
        n //= p
    return ans


K = int(input())

primes: Counter = Counter()

k = K
mx_pr = 0

for i in range(2, math.floor(math.sqrt(K)) + 1):
    while k % i == 0:
        primes[i] += 1
        k //= i
if k > 1:
    primes[k] += 1

ans = 0

for p, e in primes.items():
    f = 0
    n = p
    while True:
        f += how_many(n, p)
        if f >= e:
            ans = max(ans, n)
            break
        n += 1

print(ans)
