from math import floor n = int(input()) ans = n for j in range(1, 61): i = floor(n**(1/j)) ans = min(ans, i+j+(n-i**j)) print(ans)