import sys import numpy as np readline = sys.stdin.readline l = int(input()) n = int(input()) w = np.array(readline().split(), dtype=np.int64) w.sort() s = np.cumsum(w) ans = np.searchsorted(s, l, side='right') + 1 print(ans)