L = int(input()) N = int(input()) W = sorted(list(map(int, input().split()))) c = 0 c = c + w[i] if c <= L: for i in range(N-1): c + W[i] else: print(i)