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)