n=gets.to_i l=gets.to_i a=gets.split.map(&:to_i).sort s=0 p l.times{|i|s+=a[i];break(i)if s>n}