while n = gets.to_i
  break if n == 0
  ans = 1000
  ((n**(1.0/3.0)).ceil).downto(0) do |i|
    k = n - i * i * i
    if k >= 0
      ((k**(1.0/2.0)).ceil).downto(0) do |j|
        ans = [ans, i + j + (k - j * j)].min if k - j * j >= 0
      end
    end
  end
  p ans
end