n = int(eval(input()))

l = []

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

    for j in range(2,100):

        if i**j <= n:

            l.append(i**j)

print((max(l)))
n = int(eval(input()))

l = []

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

    for j in range(2,10):

        if i**j <= n:

            l.append(i**j)

print((max(l)))
n = int(eval(input()))
l = []
for i in range(1, n + 1):
    for j in range(2, 100):
        if i**j <= n:
            l.append(i**j)
print((max(l)))

n = int(eval(input()))
l = []
for i in range(1, n + 1):
    for j in range(2, 10):
        if i**j <= n:
            l.append(i**j)
print((max(l)))

-    for j in range(2, 100): +    for j in range(2, 10):