x = int(eval(input()))

print((max([pow(i, j) for i in range(1, 32)

           for j in range(2, 10) if pow(i, j) <= x])))

x = int(eval(input()))



table = [False] * -~x

table[1] = True

for i in range(2, 32):

    j = i * i

    while j <= x:

        table[j] = True

        j *= i



print((max(i for i in range(x + 1) if table[i])))

x = int(eval(input()))
print((max([pow(i, j) for i in range(1, 32) for j in range(2, 10) if pow(i, j) <= x])))

x = int(eval(input()))
table = [False] * -~x
table[1] = True
for i in range(2, 32):
    j = i * i
    while j <= x:
        table[j] = True
        j *= i
print((max(i for i in range(x + 1) if table[i])))

-print((max([pow(i, j) for i in range(1, 32) for j in range(2, 10) if pow(i, j) <= x]))) +table = [False] * -~x +table[1] = True +for i in range(2, 32): +    j = i * i +    while j <= x: +        table[j] = True +        j *= i +print((max(i for i in range(x + 1) if table[i])))