inf = float('inf')

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

dp = [inf]*(n+1)
dp[0] = 0
for i in range(1,n+1):
    for ci in c:
        if i - ci >= 0:
            dp[i] = min(dp[i], dp[i-ci] + 1)

ans = dp[n]
print(ans) inf = float('inf') inf float('inf') float 'inf' 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 = [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 ci in c:
        if i - ci >= 0:
            dp[i] = min(dp[i], dp[i-ci] + 1) i range(1,n+1) range 1 n+1 n 1 for ci in c:
        if i - ci >= 0:
            dp[i] = min(dp[i], dp[i-ci] + 1) ci c if i - ci >= 0:
            dp[i] = min(dp[i], dp[i-ci] + 1) i - ci >= 0 i - ci i ci 0 dp[i] = min(dp[i], dp[i-ci] + 1) dp[i] dp i min(dp[i], dp[i-ci] + 1) min dp[i] dp i dp[i-ci] + 1 dp[i-ci] dp i-ci i ci 1 ans = dp[n] ans dp[n] dp n print(ans) print ans ans = dp[n] dp[n] ans inf = float('inf') float('inf') inf dp = [inf]*(n+1) [inf]*(n+1) dp 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 = float('inf')

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

dp = [inf]*(n+1)
dp[0] = 0
for i in range(1,n+1):
    for ci in c:
        if i - ci >= 0:
            dp[i] = min(dp[i], dp[i-ci] + 1)

ans = dp[n]
print(ans)
