inf=10**9
n,m=map(int,input().split())
C=list(map(int,input().split()))

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

DP=[inf]*(n+1)
DP[0]=0
for i in range(n+1):
    for c in C:
        if 0<=i+c<=n:
            DP[i+c]=min(DP[i+c],DP[i]+1)
print(DP[n])
