n,m=map(int,input().split())
C=list(map(int,input().split()))
dp=[0]*(n+1)
dp[0]=1

for i in range(m):
    for j in range(n+1):
        if dp[j]!=0:
            if j+C[i]<=n:
                if dp[j+C[i]]==0:
                    dp[j+C[i]]=dp[j]+1
                else:
                    dp[j+C[i]]=min(dp[j]+1,dp[j+C[i]])
    #print(dp)
print(dp[n]-1) 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=[0]*(n+1) dp [0]*(n+1) [0] 0 n+1 n 1 dp[0]=1 dp[0] dp 0 1 for i in range(m):
    for j in range(n+1):
        if dp[j]!=0:
            if j+C[i]<=n:
                if dp[j+C[i]]==0:
                    dp[j+C[i]]=dp[j]+1
                else:
                    dp[j+C[i]]=min(dp[j]+1,dp[j+C[i]])
    #print(dp) i range(m) range m for j in range(n+1):
        if dp[j]!=0:
            if j+C[i]<=n:
                if dp[j+C[i]]==0:
                    dp[j+C[i]]=dp[j]+1
                else:
                    dp[j+C[i]]=min(dp[j]+1,dp[j+C[i]])
    #print(dp) j range(n+1) range n+1 n 1 if dp[j]!=0:
            if j+C[i]<=n:
                if dp[j+C[i]]==0:
                    dp[j+C[i]]=dp[j]+1
                else:
                    dp[j+C[i]]=min(dp[j]+1,dp[j+C[i]])
    #print(dp) dp[j]!=0 dp[j] dp j 0 if j+C[i]<=n:
                if dp[j+C[i]]==0:
                    dp[j+C[i]]=dp[j]+1
                else:
                    dp[j+C[i]]=min(dp[j]+1,dp[j+C[i]])
    #print(dp) j+C[i]<=n j+C[i] j C[i] C i n if dp[j+C[i]]==0:
                    dp[j+C[i]]=dp[j]+1
                else:
                    dp[j+C[i]]=min(dp[j]+1,dp[j+C[i]])
    #print(dp) dp[j+C[i]]==0 dp[j+C[i]] dp j+C[i] j C[i] C i 0 dp[j+C[i]]=dp[j]+1 dp[j+C[i]] dp j+C[i] j C[i] C i dp[j]+1 dp[j] dp j 1 dp[j+C[i]]=min(dp[j]+1,dp[j+C[i]]) dp[j+C[i]] dp j+C[i] j C[i] C i min(dp[j]+1,dp[j+C[i]]) min dp[j]+1 dp[j] dp j 1 dp[j+C[i]] dp j+C[i] j C[i] C i print(dp[n]-1) print dp[n]-1 dp[n] dp n 1 m=map(int,input().split()) map(int,input().split()) m dp=[0]*(n+1) [0]*(n+1) dp 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()))
dp=[0]*(n+1)
dp[0]=1

for i in range(m):
    for j in range(n+1):
        if dp[j]!=0:
            if j+C[i]<=n:
                if dp[j+C[i]]==0:
                    dp[j+C[i]]=dp[j]+1
                else:
                    dp[j+C[i]]=min(dp[j]+1,dp[j+C[i]])
    #print(dp)
print(dp[n]-1)
