x = int(eval(input()))

a = 0

for i in range(1,x+1):

    for j in range(2,10):

        if i**j <= x:

            a = max(a,i**j)

print(a)
x = int(eval(input()))

a = 1

for i in range(1,x):

    for j in range(2,x):

        if i**j <= x:

            a = max(a,i**j)

        else:

          break

print(a)
x = int(eval(input()))
a = 0
for i in range(1, x + 1):
    for j in range(2, 10):
        if i**j <= x:
            a = max(a, i**j)
print(a)

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

-a = 0 -for i in range(1, x + 1): -    for j in range(2, 10): +a = 1 +for i in range(1, x): +    for j in range(2, x): +        else: +            break