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

dp = [0] + [float('inf')] * N

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

dp = [0] + [float('inf')] * N

for c in C:
    for i in range(N+1):
        if i >= c:
            dp[i] = min(dp[i], dp[i-c]+1)
print(dp[-1])


