i=input l=int(i()) i() W=sorted(map(int,i().split())) while sum(W)>l:W.pop() print(len(W))