loop do
  e = gets.to_i
  if e == 0
    exit
  else
    min = 1E9
    maxZ = (e ** (1 / 3.0)).to_i
    for z in 0 .. maxZ
      left = e - z ** 3
      maxY = (left ** (1 / 2.0)).to_i
      for y in 0 .. maxY
        x = left - y ** 2
        tmp = x + y + z
        if min > tmp
          min = tmp
        end
      end
    end
    puts min
  end
end

