l=gets.to_i n = gets.to_i a=gets.split.map(&:to_i).sort sum = 0 n.times{|i| sum += a[i] if sum > l puts i+1 break end }