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

dp=[[0]*(n+1) for i in range(m)]#dp[i][j]はi番目の硬貨までを使ってj円払う最小の枚数
for i in range(n+1):
    dp[0][i]=i
for j in range(m):
    dp[j][0]=0
    dp[j][1]=1
for i in range(1,m):
    for j in range(n+1):
        if(j-c[i]>=0):
            dp[i][j]=min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j]=dp[i-1][j]
print(dp[m-1][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 [0]*(n+1) for i in range(m) for i in range(m) i range(m) range m for i in range(m) [0]*(n+1) [0] 0 n+1 n 1 dp=[[0]*(n+1) for i in range(m)] dp [[0]*(n+1) for i in range(m)] for i in range(n+1):
    dp[0][i]=i i range(n+1) range n+1 n 1 dp[0][i]=i dp[0][i] [0] dp 0 i i for j in range(m):
    dp[j][0]=0
    dp[j][1]=1 j range(m) range m dp[j][0]=0 dp[j][0] [j] dp j 0 0 dp[j][1]=1 dp[j][1] [j] dp j 1 1 for i in range(1,m):
    for j in range(n+1):
        if(j-c[i]>=0):
            dp[i][j]=min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j]=dp[i-1][j] i range(1,m) range 1 m for j in range(n+1):
        if(j-c[i]>=0):
            dp[i][j]=min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j]=dp[i-1][j] j range(n+1) range n+1 n 1 if(j-c[i]>=0):
            dp[i][j]=min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j]=dp[i-1][j] j-c[i]>=0 j-c[i] j c[i] c i 0 dp[i][j]=min(dp[i-1][j],dp[i][j-c[i]]+1) dp[i][j] [i] dp i j min(dp[i-1][j],dp[i][j-c[i]]+1) min dp[i-1][j] [i-1] dp i-1 i 1 j dp[i][j-c[i]]+1 dp[i][j-c[i]] [i] dp i j-c[i] j c[i] c i 1 dp[i][j]=dp[i-1][j] dp[i][j] [i] dp i j dp[i-1][j] [i-1] dp i-1 i 1 j print(dp[m-1][n]) print dp[m-1][n] [m-1] dp m-1 m 1 n c=list(map(int,input().split())) list(map(int,input().split())) c m=map(int,input().split()) map(int,input().split()) m n,m=map(int,input().split()) map(int,input().split()) n dp=[[0]*(n+1) for i in range(m)] [[0]*(n+1) for i in range(m)] dp
n,m=map(int,input().split())
c=list(map(int,input().split()))

dp=[[0]*(n+1) for i in range(m)]#dp[i][j]はi番目の硬貨までを使ってj円払う最小の枚数
for i in range(n+1):
    dp[0][i]=i
for j in range(m):
    dp[j][0]=0
    dp[j][1]=1
for i in range(1,m):
    for j in range(n+1):
        if(j-c[i]>=0):
            dp[i][j]=min(dp[i-1][j],dp[i][j-c[i]]+1)
        else:
            dp[i][j]=dp[i-1][j]
print(dp[m-1][n])
