n = int(input()) ans = 10**18 for j in range(61): if j == 0: ans = min(ans,n) else: i = int(n**(1/j)) k = n - i**j ans = min(ans,i+j+k) print(ans)