n=int(input()) ans=10**10 for i in range(2,10001): for j in range(1,101): if n<=i**j: ans=min(i*j,ans) break print(ans)