from functools import cache @cache def bit_subsets(bit: int) -> list[int]: res = [] b = bit while b: res.append(b) b = (b - 1) & bit return res T = int(input()) N = int(input()) tasks = [] for i in range(N): tasks.append(int(input())) b2sum = [0] * (1 << N) for i in range(1 << N): t = 0 for j in range(N): if i & (1 << j): t += tasks[j] b2sum[i] = t full = (1 << N) - 1 dp = [False] * (1 << N) dp[0] = True for i in range(N): pp = dp.copy() dp, pp = pp, dp for b in range(1 << N): if not pp[b]: continue cb = full - b # 補集合 for sb in bit_subsets(cb): if b2sum[sb] <= T: dp[sb | b] = True if dp[full]: print(i+1) break