while n = gets.to_i
  break if n == 0
  res = n
  for x in (0..(n**(1.0/3.0)).ceil)
    c = x ** 3
    if (k = n - c) >= 0
      y = Math.sqrt(k).to_i
      z = k - y * y
      res = [res, x + y + z].min
    end
  end
  p res
end