x = int(eval(input()))

ans = 1

for b in range(1, 1001):

    for p in range(2, 11):

        now = b ** p

        if now <= x:

            ans = max(ans, now)

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

ans = 0

for b in range(1, 32):

    for p in range(2, 10):

        exp = b ** p

        if exp <= X:

            ans = max(ans, exp)

print(ans)
x = int(eval(input()))
ans = 1
for b in range(1, 1001):
    for p in range(2, 11):
        now = b**p
        if now <= x:
            ans = max(ans, now)
print(ans)

X = int(eval(input()))
ans = 0
for b in range(1, 32):
    for p in range(2, 10):
        exp = b**p
        if exp <= X:
            ans = max(ans, exp)
print(ans)

-x = int(eval(input())) -ans = 1 -for b in range(1, 1001): -    for p in range(2, 11): -        now = b**p -        if now <= x: -            ans = max(ans, now) +X = int(eval(input())) +ans = 0 +for b in range(1, 32): +    for p in range(2, 10): +        exp = b**p +        if exp <= X: +            ans = max(ans, exp)