# high = 1 # l = width of big block # wi = width of each block # n = count of each block l = gets.to_i n = gets.to_i wi_array = gets.split.map!{|x| x.to_i} result = 0 # loop for wi in wi_array.sort l = l - wi if l >= 0 then result += 1 else break end end print result exit