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

INF = 10**12

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

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

for i in range(m):
    T[i][0] = 0

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

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

INF = 10**12

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

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

for i in range(m):
    T[i][0] = 0

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

print(T[m-1][n])