n=int(input()) m=int(input()) list=[int(i) for i in input().split()] list.sort() c=0 while n>0 and c0: n=n-list[c] else: print(c) break c=c+1