X = int(eval(input()))

b = 1

p = 2

ans = 0

for b in range(1, X + 1):

    for p in range(2, 10):

        if b ** p <= X:

            ans = max(ans, b ** p)



print(ans)

X = int(eval(input()))



ans = 1

for b in range(1, X + 1):

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

        if b ** p <= X:

            ans = max(ans, b ** p)

        else:

            break



print(ans)

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

X = int(eval(input()))
ans = 1
for b in range(1, X + 1):
    for p in range(2, X + 1):
        if b**p <= X:
            ans = max(ans, b**p)
        else:
            break
print(ans)

-b = 1 -p = 2 -ans = 0 +ans = 1 -    for p in range(2, 10): +    for p in range(2, X + 1): +        else: +            break