get_box, get_number = gets.chomp.split.map(&:to_i) boxes = gets.chomp.split.map(&:to_i).sort! count = 0 boxes.each do |box| get_number -= box break if get_number < 0 count += 1 end puts count