a=0 I=input l=int(I()) n=int(I()) w=list(map(int,(I().split()))) w.sort() for i in w: a+=i if a >= l: break print(w.index(i))