l,n,a,i=int(input()),int(input()),sorted(list(mao(int,input().split()))),0 while i=0:l-=a[i];i+=1 print(i)