X=int(eval(input()))



ans=1

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

    j = 1

    n = i

    while n*i <= X:

        n *= i

        j += 1

    ans = max(ans, n)



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

ans=1

for i in range(1,1000):

    for j in range(2,1000):

        t=i**j

        if t>X: break

        ans = max(ans, t)

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

X = int(eval(input()))
ans = 1
for i in range(1, 1000):
    for j in range(2, 1000):
        t = i**j
        if t > X:
            break
        ans = max(ans, t)
print(ans)

-for i in range(2, int(X**0.5) + 1): -    j = 1 -    n = i -    while n * i <= X: -        n *= i -        j += 1 -    ans = max(ans, n) +for i in range(1, 1000): +    for j in range(2, 1000): +        t = i**j +        if t > X: +            break +        ans = max(ans, t)