import math

L = int(input())
N = input()
W = sorted(list(map(int, input().split())))
c = L
count = 0
for i in W:
    x = c - i
    if x < 0:
        break
    c = x
    count += 1
print(count)