# ABC097 B  Exponential

x = int(eval(input()))

ans = 0



for i in range(1,33):

    for j in range(2,10):

        t = i**j

        if t <= x:

            ans = max(t,ans)

print(ans)
x=int(eval(input()))

exp=[0]*(x+1)

exp[1]=1

ans=0

for i in range(2,x+1):

    t=i*i

    while t<=x:

        exp[t]=1

        t*=i



for i in range(1,x+1):

    if exp[i]:

        ans=max(i,ans)

print(ans)
# ABC097 B  Exponential
x = int(eval(input()))
ans = 0
for i in range(1, 33):
    for j in range(2, 10):
        t = i**j
        if t <= x:
            ans = max(t, ans)
print(ans)

x = int(eval(input()))
exp = [0] * (x + 1)
exp[1] = 1
ans = 0
for i in range(2, x + 1):
    t = i * i
    while t <= x:
        exp[t] = 1
        t *= i
for i in range(1, x + 1):
    if exp[i]:
        ans = max(i, ans)
print(ans)

-# ABC097 B  Exponential +exp = [0] * (x + 1) +exp[1] = 1 -for i in range(1, 33): -    for j in range(2, 10): -        t = i**j -        if t <= x: -            ans = max(t, ans) +for i in range(2, x + 1): +    t = i * i +    while t <= x: +        exp[t] = 1 +        t *= i +for i in range(1, x + 1): +    if exp[i]: +        ans = max(i, ans)