l=input() input() w=map(int,raw_input().split()) w.sort() n=0 for i in w: l-=i if l<0:break n+=1 print n