import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) T = int(input()) N = int(input()) A = [int(input()) for _ in range(N)] dp = [N] * (1 << N) dp[0] = 0 for S in range(1, 1 << N): time = 0 for i, t in enumerate(A): if (S >> i) & 1: time += t if time <= T: dp[S] = 1 for S in range(1, 1 << N): T = S while T: dp[S] = min(dp[S], dp[T] + dp[S ^ T]) T = (T - 1) & S print(dp[(1 << N)-1])