from math import sqrt

X=int(eval(input()))

ans=0

for i in range(1,int(sqrt(X))+1):

    now=i

    b=2

    while i!=1 and X>=i**b:

        now=i**b

        b+=1

    ans=max(ans, now)

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

ans=0

for i in range(1,33):

    for j in range(2,11):

        now=i**j

        if ans<now and now<=X:

            ans=now



print(ans)

from math import sqrt

X = int(eval(input()))
ans = 0
for i in range(1, int(sqrt(X)) + 1):
    now = i
    b = 2
    while i != 1 and X >= i**b:
        now = i**b
        b += 1
    ans = max(ans, now)
print(ans)

X = int(eval(input()))
ans = 0
for i in range(1, 33):
    for j in range(2, 11):
        now = i**j
        if ans < now and now <= X:
            ans = now
print(ans)

-from math import sqrt - -for i in range(1, int(sqrt(X)) + 1): -    now = i -    b = 2 -    while i != 1 and X >= i**b: -        now = i**b -        b += 1 -    ans = max(ans, now) +for i in range(1, 33): +    for j in range(2, 11): +        now = i**j +        if ans < now and now <= X: +            ans = now