n=int(input()) ans=10**18 for i in range(200000): for j in range(50): if i==0 and j==0: continue if pow(i,j)>n: break k=n-pow(i,j) ans=min(ans,i+j+k) print(ans)