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