require 'benchmark'

loop do
  e = gets.to_i
  break if e == 0
  x_max = e
  y_max = (e**(1.0 / 2.0)).round
  z_max = (e**(1.0 / 3.0)).round
  min = e
  z_max.downto(0) do |z|
    0.upto(y_max) do |y|
      x = e - y**2 - z**3
      break if x < 0
      sum = x + y + z
      min = sum if sum < min
    end
  end
  puts min
end