l,n,a=int(input()),int(input()),sorted(list(map(int,input().split()))) for i in range(n): l-=a[i] if l<0:print(i);exit() print(n)