include Math
while true
  e = gets.chomp.to_i
  break if e == 0
  z_max = (e ** (1.0 / 3.0)).floor
  min = -1
  z_max.times do |i|
    z = i + 1
    rest = e - (z ** 3)
    y = (rest ** (1.0 / 2.0)).floor
    x = rest - (y ** 2)
    temp_min = x + y + z
    if min < 0 || temp_min < min
      min = temp_min
    end
  end
  puts min
end

