L = input() N = input() e = map(int, raw_input().split()) e.sort() i = 0 j = 0 while i < L: i = i + sum(e[0:j+1]) j = j + 1 else: print j