import sys a = [input() for l in range(3)] wide = int(a[0]) num = int(a[1]) blk = a[2].split() blk.sort() total = 0 for i in range(int(num)): total = total + int(blk[i]) if total >= wide: print(i) break