import copy

N, M = map(int, input().split())
c = [0]
c += list(map(int, input().split()))
memo = [N] * (N+1)
flag = [False] * (N+1)
flag[0] = True
memo[0] = 0

for i in range(1, N+1):
    if not flag[i]:
        flag[i] = True
        for j in range(1, M+1):
            if i >= c[j]:
                memo[i] = min(memo[i], memo[i-c[j]] + 1)

print(memo[N])
 import copy copy N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M c = [0] c [0] 0 c += list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split memo = [N] * (N+1) memo [N] * (N+1) [N] N N+1 N 1 flag = [False] * (N+1) flag [False] * (N+1) [False] False N+1 N 1 flag[0] = True flag[0] flag 0 True memo[0] = 0 memo[0] memo 0 0 for i in range(1, N+1):
    if not flag[i]:
        flag[i] = True
        for j in range(1, M+1):
            if i >= c[j]:
                memo[i] = min(memo[i], memo[i-c[j]] + 1) i range(1, N+1) range 1 N+1 N 1 if not flag[i]:
        flag[i] = True
        for j in range(1, M+1):
            if i >= c[j]:
                memo[i] = min(memo[i], memo[i-c[j]] + 1) not flag[i] flag[i] flag i flag[i] = True flag[i] flag i True for j in range(1, M+1):
            if i >= c[j]:
                memo[i] = min(memo[i], memo[i-c[j]] + 1) j range(1, M+1) range 1 M+1 M 1 if i >= c[j]:
                memo[i] = min(memo[i], memo[i-c[j]] + 1) i >= c[j] i c[j] c j memo[i] = min(memo[i], memo[i-c[j]] + 1) memo[i] memo i min(memo[i], memo[i-c[j]] + 1) min memo[i] memo i memo[i-c[j]] + 1 memo[i-c[j]] memo i-c[j] i c[j] c j 1 print(memo[N]) print memo[N] memo N c = [0] [0] c memo = [N] * (N+1) [N] * (N+1) memo c += list(map(int, input().split())) list(map(int, input().split())) c M = map(int, input().split()) map(int, input().split()) M flag = [False] * (N+1) [False] * (N+1) flag N, M = map(int, input().split()) map(int, input().split()) N
import copy

N, M = map(int, input().split())
c = [0]
c += list(map(int, input().split()))
memo = [N] * (N+1)
flag = [False] * (N+1)
flag[0] = True
memo[0] = 0

for i in range(1, N+1):
    if not flag[i]:
        flag[i] = True
        for j in range(1, M+1):
            if i >= c[j]:
                memo[i] = min(memo[i], memo[i-c[j]] + 1)

print(memo[N])

