INF = float('inf')
N, M = map(int, input().split())
C = [int(c) for c in input().split()]
T = [[INF] * (N + 1) for _ in range(M + 1)]
for i in range(M + 1):
    T[i][0] = 0

for i in range(1, M + 1):
        for j in range(1, N + 1):
            if N + 1 < j - C[i - 1] or j - C[i - 1] < 0:
                T[i][j] = T[i - 1][j]
            else:
                T[i][j] = min(T[i - 1][j], T[i][j - C[i - 1]] + 1)

ans = []
for i in range(1, M + 1):
    ans.append(T[i][N])

print(min(ans))
 INF = float('inf') INF float('inf') float 'inf' N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M int(c) for c in input().split() for c in input().split() c input().split() ().split () input split for c in input().split() int(c) int c C = [int(c) for c in input().split()] C [int(c) for c in input().split()] [INF] * (N + 1) for _ in range(M + 1) for _ in range(M + 1) _ range(M + 1) range M + 1 M 1 for _ in range(M + 1) [INF] * (N + 1) [INF] INF N + 1 N 1 T = [[INF] * (N + 1) for _ in range(M + 1)] T [[INF] * (N + 1) for _ in range(M + 1)] for i in range(M + 1):
    T[i][0] = 0 i range(M + 1) range M + 1 M 1 T[i][0] = 0 T[i][0] [i] T i 0 0 for i in range(1, M + 1):
        for j in range(1, N + 1):
            if N + 1 < j - C[i - 1] or j - C[i - 1] < 0:
                T[i][j] = T[i - 1][j]
            else:
                T[i][j] = min(T[i - 1][j], T[i][j - C[i - 1]] + 1) i range(1, M + 1) range 1 M + 1 M 1 for j in range(1, N + 1):
            if N + 1 < j - C[i - 1] or j - C[i - 1] < 0:
                T[i][j] = T[i - 1][j]
            else:
                T[i][j] = min(T[i - 1][j], T[i][j - C[i - 1]] + 1) j range(1, N + 1) range 1 N + 1 N 1 if N + 1 < j - C[i - 1] or j - C[i - 1] < 0:
                T[i][j] = T[i - 1][j]
            else:
                T[i][j] = min(T[i - 1][j], T[i][j - C[i - 1]] + 1) N + 1 < j - C[i - 1] or j - C[i - 1] < 0 N + 1 < j - C[i - 1] N + 1 N 1 j - C[i - 1] j C[i - 1] C i - 1 i 1 j - C[i - 1] < 0 j - C[i - 1] j C[i - 1] C i - 1 i 1 0 T[i][j] = T[i - 1][j] T[i][j] [i] T i j T[i - 1][j] [i - 1] T i - 1 i 1 j T[i][j] = min(T[i - 1][j], T[i][j - C[i - 1]] + 1) T[i][j] [i] T i j min(T[i - 1][j], T[i][j - C[i - 1]] + 1) min T[i - 1][j] [i - 1] T i - 1 i 1 j T[i][j - C[i - 1]] + 1 T[i][j - C[i - 1]] [i] T i j - C[i - 1] j C[i - 1] C i - 1 i 1 1 ans = [] ans [] for i in range(1, M + 1):
    ans.append(T[i][N]) i range(1, M + 1) range 1 M + 1 M 1 ans.append(T[i][N]) ans.append ans append T[i][N] [i] T i N print(min(ans)) print min(ans) min ans N, M = map(int, input().split()) map(int, input().split()) N ans = [] [] ans C = [int(c) for c in input().split()] [int(c) for c in input().split()] C M = map(int, input().split()) map(int, input().split()) M T = [[INF] * (N + 1) for _ in range(M + 1)] [[INF] * (N + 1) for _ in range(M + 1)] T INF = float('inf') float('inf') INF
INF = float('inf')
N, M = map(int, input().split())
C = [int(c) for c in input().split()]
T = [[INF] * (N + 1) for _ in range(M + 1)]
for i in range(M + 1):
    T[i][0] = 0

for i in range(1, M + 1):
        for j in range(1, N + 1):
            if N + 1 < j - C[i - 1] or j - C[i - 1] < 0:
                T[i][j] = T[i - 1][j]
            else:
                T[i][j] = min(T[i - 1][j], T[i][j - C[i - 1]] + 1)

ans = []
for i in range(1, M + 1):
    ans.append(T[i][N])

print(min(ans))

