x=int(eval(input()))

v=[]

for i in range(1,32):

    for j in range(2,1000):

        if i**j<=x and (i+1)**j>x:

            v.append(i**j)

print((max(v)))
x=int(eval(input()))

v=[]

for j in range(2,11):

    for i in range(1,32):

        if i**j<=x and (i+1)**j>x:

            v.append(i**j)

            break

print((max(v)))

        
x = int(eval(input()))
v = []
for i in range(1, 32):
    for j in range(2, 1000):
        if i**j <= x and (i + 1) ** j > x:
            v.append(i**j)
print((max(v)))

x = int(eval(input()))
v = []
for j in range(2, 11):
    for i in range(1, 32):
        if i**j <= x and (i + 1) ** j > x:
            v.append(i**j)
            break
print((max(v)))

-for i in range(1, 32): -    for j in range(2, 1000): +for j in range(2, 11): +    for i in range(1, 32): +            break