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

minimum = [50000] * (n+1)
minimum[0] = 0

for i in range(1,n+1):
    if minimum[i] <= 1:
        continue
    for j in range(m):
        if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1

print(minimum[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 minimum = [50000] * (n+1) minimum [50000] * (n+1) [50000] 50000 n+1 n 1 minimum[0] = 0 minimum[0] minimum 0 0 for i in range(1,n+1):
    if minimum[i] <= 1:
        continue
    for j in range(m):
        if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1 i range(1,n+1) range 1 n+1 n 1 if minimum[i] <= 1:
        continue
     minimum[i] <= 1 minimum[i] minimum i 1 continue for j in range(m):
        if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1 j range(m) range m if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1 c[j]<=i and minimum[i-c[j]] + 1 < minimum[i] c[j]<=i c[j] c j i minimum[i-c[j]] + 1 < minimum[i] minimum[i-c[j]] + 1 minimum[i-c[j]] minimum i-c[j] i c[j] c j 1 minimum[i] minimum i minimum[i] = minimum[i-c[j]]+1 minimum[i] minimum i minimum[i-c[j]]+1 minimum[i-c[j]] minimum i-c[j] i c[j] c j 1 print(minimum[n]) print minimum[n] minimum n minimum = [50000] * (n+1) [50000] * (n+1) minimum c = list(map(int,input().split())) list(map(int,input().split())) c n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m
n,m = map(int,input().split())
c = list(map(int,input().split()))

minimum = [50000] * (n+1)
minimum[0] = 0

for i in range(1,n+1):
    if minimum[i] <= 1:
        continue
    for j in range(m):
        if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1

print(minimum[n])