T = int(input()) N = int(input()) t = [int(input()) for _ in range(N)] inf = 32 dp = [inf] * (1 << N) for bit in range(1,1 << N): tmp = 0 for i in range(N): if bit >> i & 1: tmp += t[i] if tmp <= T: dp[bit] = 1 for bit in range(1,1 << N): tmp = inf T = bit while T: T -= 1 T &= bit u = dp[T] + dp[bit ^ T] if u < tmp: tmp = u if tmp < dp[bit]: dp[bit] = tmp print(dp[-1])