l = gets.to_i n = gets.to_i w = gets.split.map(&:to_i).sort sum = 0 w.each_with_index do |n, i| if l <= sum + n puts i+1 exit 0 end sum += n end puts n