from bisect import bisect_left
def minimum_groups(w, prices):
prices.sort() # 將紀念品的價格從小到大排序
n = len(prices)
groups = 0 # 紀念品被分成了幾組
left, right = 0, n - 1 # 左右指針
while left <= right:
if prices[left] + prices[right] <= w: # 如果左右紀念品的價格之和小於等於 w
left += 1 # 將左指針右移
right -= 1 # 右指針左移
groups += 1 # 分成一組
return groups
# 讀取輸入
w = int(input())
n = int(input())
prices = [int(input()) for _ in range(n)]
print(minimum_groups(w, prices))