l = gets.to_i n = gets.to_i w = gets.split.map(&:to_i) s = 0 ii = 0 w.sort.each do |i| if s <= l s += i ii += 1 else p ii - 1 break end end