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

N = [float('inf')] * (50000 + 1)
N[0] = 0
for i in range(1, 50000 + 1):
    for c in C:
        if i - c < 0:
            continue
        N[i] = min(N[i - c] + 1, N[i])

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

N = [float('inf')] * (50000 + 1)
N[0] = 0
for i in range(1, 50000 + 1):
    for c in C:
        if i - c < 0:
            continue
        N[i] = min(N[i - c] + 1, N[i])

print(N[n])
