l=gets.to_i n=gets.to_i i=0;gets.split(" ").map(&:to_i).sort!.inject(0){|s,e| s=s+e break if s>l i+=1 s } p i