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

