import math A=int(input()) ans=A for N in range(2,round(math.sqrt(A+2))+1): x=round(math.log2(A)/math.log2(N)) while A<=N**x:x-=1 x+=1 if ans>N*x: ans=N*x if N>=ans:break print(ans)