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

dp=[10**5]*(n+1)
dp[0]=0
dp[a[0]]=1

for i in range(n+1):
    for j in range(m):
        if i-a[j]>=0:
            dp[i]=min(dp[i],dp[i-a[j]]+1)
print(dp[-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a=list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split dp=[10**5]*(n+1) dp [10**5]*(n+1) [10**5] 10**5 10 5 n+1 n 1 dp[0]=0 dp[0] dp 0 0 dp[a[0]]=1 dp[a[0]] dp a[0] a 0 1 for i in range(n+1):
    for j in range(m):
        if i-a[j]>=0:
            dp[i]=min(dp[i],dp[i-a[j]]+1) i range(n+1) range n+1 n 1 for j in range(m):
        if i-a[j]>=0:
            dp[i]=min(dp[i],dp[i-a[j]]+1) j range(m) range m if i-a[j]>=0:
            dp[i]=min(dp[i],dp[i-a[j]]+1) i-a[j]>=0 i-a[j] i a[j] a j 0 dp[i]=min(dp[i],dp[i-a[j]]+1) dp[i] dp i min(dp[i],dp[i-a[j]]+1) min dp[i] dp i dp[i-a[j]]+1 dp[i-a[j]] dp i-a[j] i a[j] a j 1 print(dp[-1]) print dp[-1] dp -1 m=map(int,input().split()) map(int,input().split()) m dp=[10**5]*(n+1) [10**5]*(n+1) dp a=list(map(int,input().split())) list(map(int,input().split())) a n,m=map(int,input().split()) map(int,input().split()) n
n,m=map(int,input().split())
a=list(map(int,input().split()))

dp=[10**5]*(n+1)
dp[0]=0
dp[a[0]]=1

for i in range(n+1):
    for j in range(m):
        if i-a[j]>=0:
            dp[i]=min(dp[i],dp[i-a[j]]+1)
print(dp[-1])
