import math



X = int(eval(input()))

answer = 1

for i in range(X+1):

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

        if i ** j <= X:

            answer = max(answer, i ** j)

        else:

            break

print(answer)

X = int(eval(input()))



answer = 1

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

    j = 2

    while i**j <= X:

        answer = max(answer, i**j)

        j += 1

print(answer)
import math

X = int(eval(input()))
answer = 1
for i in range(X + 1):
    for j in range(2, X + 1):
        if i**j <= X:
            answer = max(answer, i**j)
        else:
            break
print(answer)

X = int(eval(input()))
answer = 1
for i in range(2, X + 1):
    j = 2
    while i**j <= X:
        answer = max(answer, i**j)
        j += 1
print(answer)

-import math - -for i in range(X + 1): -    for j in range(2, X + 1): -        if i**j <= X: -            answer = max(answer, i**j) -        else: -            break +for i in range(2, X + 1): +    j = 2 +    while i**j <= X: +        answer = max(answer, i**j) +        j += 1