a=int(input()) b=int(input()) c=[int(i) for i in input().split()] c.sort() for i,j in enumerate(c): a-=j if a<0: print(i) break