import sys

X = int(eval(input()))

res = 0

for b in range(1, -(-X//2)+1):

    for p in range(2, -(-X//2)+2):

        val = b**p

        if (val <= X) and (val > res):

            res = val

print(res)

import math

X = int(eval(input()))

res = 0

for b in range(1, int(math.sqrt(X))+1):

    for p in range(2, int(math.sqrt(X))+2):

        val = b**p

        if (val <= X) and (val > res):

            res = val

print(res)

import sys

X = int(eval(input()))
res = 0
for b in range(1, -(-X // 2) + 1):
    for p in range(2, -(-X // 2) + 2):
        val = b**p
        if (val <= X) and (val > res):
            res = val
print(res)

import math

X = int(eval(input()))
res = 0
for b in range(1, int(math.sqrt(X)) + 1):
    for p in range(2, int(math.sqrt(X)) + 2):
        val = b**p
        if (val <= X) and (val > res):
            res = val
print(res)

-import sys +import math -for b in range(1, -(-X // 2) + 1): -    for p in range(2, -(-X // 2) + 2): +for b in range(1, int(math.sqrt(X)) + 1): +    for p in range(2, int(math.sqrt(X)) + 2):