N=int(input()) ans=int(1e100) for i in range(1000000): x=i+2 for j in range(100): if(x**j>N): ans=min(ans,x*j) else: break print(ans)