x=int(eval(input()))

p=10

ans=0

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

    for j in range(2,p+1):

        if i**j<=x:

            ans=max(ans,i**j)

            

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

maxim=0

for i in range(2,32):

    for j in range(2,10):

        temp=i**j

        if temp<=x and maxim<temp:

            maxim=temp

print((maxim if maxim>0 else 1))
x = int(eval(input()))
p = 10
ans = 0
for i in range(1, 1 + x):
    for j in range(2, p + 1):
        if i**j <= x:
            ans = max(ans, i**j)
print(ans)

x = int(eval(input()))
maxim = 0
for i in range(2, 32):
    for j in range(2, 10):
        temp = i**j
        if temp <= x and maxim < temp:
            maxim = temp
print((maxim if maxim > 0 else 1))

-p = 10 -ans = 0 -for i in range(1, 1 + x): -    for j in range(2, p + 1): -        if i**j <= x: -            ans = max(ans, i**j) -print(ans) +maxim = 0 +for i in range(2, 32): +    for j in range(2, 10): +        temp = i**j +        if temp <= x and maxim < temp: +            maxim = temp +print((maxim if maxim > 0 else 1))