n=int(input()) ans=n for j in range(1,60): i=int(pow(n,1/j)) while i**j<=n: k=n-i**j ans=min(ans,i+j+k) i+=1 print(ans)