n=int(input()) ans=10**19 for j in range(65): ok=0 ng=10**18 while ng-ok>1: mid=(ok+ng)//2 if mid**j<=n:ok=mid else:ng=mid i=ok k=n-i**j ans=min(ans,i+j+k) print(ans)