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

INF = 10**8
dp = [INF]*(N+1)
dp[0] = 0

for i in range(1, N+1):
    for j in range(M):
        if i < C[j]:
            continue
        dp[i] = min(dp[i], dp[i-C[j]]+1)
print(dp[-1])
 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**8 INF 10**8 10 8 dp = [INF]*(N+1) dp [INF]*(N+1) [INF] INF N+1 N 1 dp[0] = 0 dp[0] dp 0 0 for i in range(1, N+1):
    for j in range(M):
        if i < C[j]:
            continue
        dp[i] = min(dp[i], dp[i-C[j]]+1) i range(1, N+1) range 1 N+1 N 1 for j in range(M):
        if i < C[j]:
            continue
        dp[i] = min(dp[i], dp[i-C[j]]+1) j range(M) range M if i < C[j]:
            continue
         i < C[j] i C[j] C j continue dp[i] = min(dp[i], dp[i-C[j]]+1) dp[i] dp i min(dp[i], dp[i-C[j]]+1) min dp[i] dp i dp[i-C[j]]+1 dp[i-C[j]] dp i-C[j] i C[j] C j 1 print(dp[-1]) print dp[-1] dp -1 M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N C = list(map(int, input().split())) list(map(int, input().split())) C dp = [INF]*(N+1) [INF]*(N+1) dp INF = 10**8 10**8 INF
N, M = map(int, input().split())
C = list(map(int, input().split()))

INF = 10**8
dp = [INF]*(N+1)
dp[0] = 0

for i in range(1, N+1):
    for j in range(M):
        if i < C[j]:
            continue
        dp[i] = min(dp[i], dp[i-C[j]]+1)
print(dp[-1])

