l = int(input()) n = int(input()) w = sorted(map(int, input().split())) cnt = 0 s = 0 for i in w: s += a if s < l: cnt += 1 else: break print(cnt)