l={};
2.times{|i|l[i]=gets.chomp.to_i};
s=gets.chomp.split.map &:to_i;
c=0;
l=l[0];
s.sort.each{|w|l-=w;
            if l<0then p c;
                exit(0) end;
                c+=1}
p c