box_width = gets.to_i box_num = gets.to_i blocks = gets.split.map(&:to_i) blocks.sort!.each_with_index{|b_w, index| box_width -= b_w if box_width < 0 puts index return end } puts box_num