x=int(eval(input()))

for i in range(x,0,-1):

    for p in range(1,int(i**.5)+1):

        for q in range(10):

            if i==p**q:

                print(i)

                break

        else:

            continue

        break

    else:

        continue

    break

x = int(eval(input()))

res = 0

for i in range(1,int(x**.5)+1):

    for j in range(2,1000):

        if i ** j > x:

            break

        res = max(res, i ** j)

print(res)

x = int(eval(input()))
for i in range(x, 0, -1):
    for p in range(1, int(i**0.5) + 1):
        for q in range(10):
            if i == p**q:
                print(i)
                break
        else:
            continue
        break
    else:
        continue
    break

x = int(eval(input()))
res = 0
for i in range(1, int(x**0.5) + 1):
    for j in range(2, 1000):
        if i**j > x:
            break
        res = max(res, i**j)
print(res)

-for i in range(x, 0, -1): -    for p in range(1, int(i**0.5) + 1): -        for q in range(10): -            if i == p**q: -                print(i) -                break -        else: -            continue -        break -    else: -        continue -    break +res = 0 +for i in range(1, int(x**0.5) + 1): +    for j in range(2, 1000): +        if i**j > x: +            break +        res = max(res, i**j) +print(res)