from heapq import heapify, heappop L, N, *W = map(int, open(0).read().split()) heapify(W) cnt = 0 while W: L -= heappop(W) if L < 0: break cnt += 1 print(cnt)