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