You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
X = int(input())
ql = []

for i in range(1,32):
    for j in range(2,11):
        ql.append(i**j)
        #print(ql)
        if max(ql) > X: 
            print(ql[-2])
            exit()
x = int(input())
c = 1

for b in range(1,x):
    for p in range(2,x):
        if b**p <= x:
            c = max(c,b**p)
        else:
            break

print(c)