a=int(input()) b=int(input()) c=list(map(int,input().split())) c.sort() count=0 total=0 for i in c: total+=i count+=1 if a<=total: print(count) break