X = int(eval(input()))

ans = 1

t = min(X, 100)

for b in range(1, t):

    for p in range(1, t):

        if b**p > ans and b**p <= X:

            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:

            break

        if b**p > ans and b**p <= X:

            ans = b**p

print(ans)
X = int(eval(input()))
ans = 1
t = min(X, 100)
for b in range(1, t):
    for p in range(1, t):
        if b**p > ans and b**p <= X:
            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:
            break
        if b**p > ans and b**p <= X:
            ans = b**p
print(ans)

-t = min(X, 100) -for b in range(1, t): -    for p in range(1, t): +for b in range(1, X + 1): +    for p in range(2, X + 1): +        if b**p > X: +            break