N, M = map(int, input().split())
c = list(map(int, input().split()))

dp = [0] + [float('inf')] * N
for m in range(M):
    ci = c[m]
    for n in range(N + 1):
        if n - ci >= 0:
            dp[n] = min(dp[n], dp[n - ci] + 1)

print(dp[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 dp = [0] + [float('inf')] * N dp [0] + [float('inf')] * N [0] 0 [float('inf')] * N [float('inf')] float('inf') float 'inf' N for m in range(M):
    ci = c[m]
    for n in range(N + 1):
        if n - ci >= 0:
            dp[n] = min(dp[n], dp[n - ci] + 1) m range(M) range M ci = c[m] ci c[m] c m for n in range(N + 1):
        if n - ci >= 0:
            dp[n] = min(dp[n], dp[n - ci] + 1) n range(N + 1) range N + 1 N 1 if n - ci >= 0:
            dp[n] = min(dp[n], dp[n - ci] + 1) n - ci >= 0 n - ci n ci 0 dp[n] = min(dp[n], dp[n - ci] + 1) dp[n] dp n min(dp[n], dp[n - ci] + 1) min dp[n] dp n dp[n - ci] + 1 dp[n - ci] dp n - ci n ci 1 print(dp[N]) print dp[N] dp N M = map(int, input().split()) map(int, input().split()) M c = list(map(int, input().split())) list(map(int, input().split())) c dp = [0] + [float('inf')] * N [0] + [float('inf')] * N dp ci = c[m] c[m] ci N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())
c = list(map(int, input().split()))

dp = [0] + [float('inf')] * N
for m in range(M):
    ci = c[m]
    for n in range(N + 1):
        if n - ci >= 0:
            dp[n] = min(dp[n], dp[n - ci] + 1)

print(dp[N])
