L=input();N=input() for w in sorted(map(int,raw_input().split())):L-=w;N-=L<0 print N