*r,=list(range(1,32));x=int(eval(input()));print((max(b**p*(b**p<=x)for p in r[1:]for b in r)))
r=list(range(1,32));x=int(eval(input()));print((max(b**p*(b**p<=x)for p in r[1:]for b in r)))
(*r,) = list(range(1, 32))
x = int(eval(input()))
print((max(b**p * (b**p <= x) for p in r[1:] for b in r)))

r = list(range(1, 32))
x = int(eval(input()))
print((max(b**p * (b**p <= x) for p in r[1:] for b in r)))

-(*r,) = list(range(1, 32)) +r = list(range(1, 32))