#34972: python AC


1554101-0@g.puiching.edu.mo (P6A29_1300題了)


w = int(input())
n = int(input())
prices = [0] + [int(input()) for _ in range(n)]
prices.sort()

left, right = 1, n
cnt = 0

while left <= right:
    if prices[left] + prices[right] <= w:
        left += 1
        right -= 1
    else:
        right -= 1
    cnt += 1

print(cnt)