X = int(eval(input()))

ans = 1

for b in range(2,X):

    for p in range(2,X):

        tmp_ans = b ** p

        if tmp_ans > X:

            break

        if tmp_ans > ans:

            ans = tmp_ans

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

ans = 1

for b in range(1, X):

    for p in range(2, X):

        tmp = b ** p

        if tmp > X:

            break

        if ans < tmp:

            ans = tmp

print(ans)
X = int(eval(input()))
ans = 1
for b in range(2, X):
    for p in range(2, X):
        tmp_ans = b**p
        if tmp_ans > X:
            break
        if tmp_ans > ans:
            ans = tmp_ans
print(ans)

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

-for b in range(2, X): +for b in range(1, X): -        tmp_ans = b**p -        if tmp_ans > X: +        tmp = b**p +        if tmp > X: -        if tmp_ans > ans: -            ans = tmp_ans +        if ans < tmp: +            ans = tmp