T = int(input()) N = int(input()) t = [int(input()) for _ in range(N)] INF = 10**18 dp = [[INF]*2 for _ in range(1 << N)] dp[0] = [1, 0] for S in range(1 << N): for i in range(N): if (S >> i) & 1: continue p = dp[S][:] if p[1] + t[i] <= T: p[1] += t[i] else: p[0] += 1 p[1] = t[i] dp[S | (1 << i)] = min(dp[S | (1 << i)], p) print(dp[(1 << N) - 1][0])