n, m = map(int, input().split())
c = list(map(int, input().split()))

INF = 10**12

T = [i for i in range(n+1)]

for i in range(m):
    for j in range(1, n+1):
        if j - c[i] >= 0:
            T[j] = min(T[j], T[j - c[i]] + 1)

print(T[n]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split INF = 10**12 INF 10**12 10 12 i for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) i T = [i for i in range(n+1)] T [i for i in range(n+1)] for i in range(m):
    for j in range(1, n+1):
        if j - c[i] >= 0:
            T[j] = min(T[j], T[j - c[i]] + 1) i range(m) range m for j in range(1, n+1):
        if j - c[i] >= 0:
            T[j] = min(T[j], T[j - c[i]] + 1) j range(1, n+1) range 1 n+1 n 1 if j - c[i] >= 0:
            T[j] = min(T[j], T[j - c[i]] + 1) j - c[i] >= 0 j - c[i] j c[i] c i 0 T[j] = min(T[j], T[j - c[i]] + 1) T[j] T j min(T[j], T[j - c[i]] + 1) min T[j] T j T[j - c[i]] + 1 T[j - c[i]] T j - c[i] j c[i] c i 1 print(T[n]) print T[n] T n c = list(map(int, input().split())) list(map(int, input().split())) c n, m = map(int, input().split()) map(int, input().split()) n T = [i for i in range(n+1)] [i for i in range(n+1)] T INF = 10**12 10**12 INF m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
c = list(map(int, input().split()))

INF = 10**12

T = [i for i in range(n+1)]

for i in range(m):
    for j in range(1, n+1):
        if j - c[i] >= 0:
            T[j] = min(T[j], T[j - c[i]] + 1)

print(T[n])