i=input L,N=map(int,(i(),i())) W=sorted(map(int,i().split())) a=0 while W: L-=W.pop(0) a+=(L>=0) print(a)