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

dp=[[float("inf") for i in range(n+1)] for j in range(m+1)]

for i in range(m+1):
    dp[i][0]=0

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

print(int(dp[m][n])) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m lst=list(map(int,input().split())) lst list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split [float("inf") for i in range(n+1)] for j in range(m+1) for j in range(m+1) j range(m+1) range m+1 m 1 for j in range(m+1) [float("inf") for i in range(n+1)] dp=[[float("inf") for i in range(n+1)] for j in range(m+1)] dp [[float("inf") for i in range(n+1)] for j in range(m+1)] for i in range(m+1):
    dp[i][0]=0 i range(m+1) range m+1 m 1 dp[i][0]=0 dp[i][0] [i] dp i 0 0 for i in range(1,m+1):
    for j in range(1,n+1):
        if j-lst[i-1]>=0:
            dp[i][j]=min(dp[i-1][j],dp[i][j-lst[i-1]]+1)
        else : dp[i][j]=dp[i-1][j] i range(1,m+1) range 1 m+1 m 1 for j in range(1,n+1):
        if j-lst[i-1]>=0:
            dp[i][j]=min(dp[i-1][j],dp[i][j-lst[i-1]]+1)
        else : dp[i][j]=dp[i-1][j] j range(1,n+1) range 1 n+1 n 1 if j-lst[i-1]>=0:
            dp[i][j]=min(dp[i-1][j],dp[i][j-lst[i-1]]+1)
        else : dp[i][j]=dp[i-1][j] j-lst[i-1]>=0 j-lst[i-1] j lst[i-1] lst i-1 i 1 0 dp[i][j]=min(dp[i-1][j],dp[i][j-lst[i-1]]+1) dp[i][j] [i] dp i j min(dp[i-1][j],dp[i][j-lst[i-1]]+1) min dp[i-1][j] [i-1] dp i-1 i 1 j dp[i][j-lst[i-1]]+1 dp[i][j-lst[i-1]] [i] dp i j-lst[i-1] j lst[i-1] lst i-1 i 1 1 print(int(dp[m][n])) print int(dp[m][n]) int dp[m][n] [m] dp m n n,m=map(int,input().split()) map(int,input().split()) n dp=[[float("inf") for i in range(n+1)] for j in range(m+1)] [[float("inf") for i in range(n+1)] for j in range(m+1)] dp lst=list(map(int,input().split())) list(map(int,input().split())) lst m=map(int,input().split()) map(int,input().split()) m
n,m=map(int,input().split())
lst=list(map(int,input().split()))

dp=[[float("inf") for i in range(n+1)] for j in range(m+1)]

for i in range(m+1):
    dp[i][0]=0

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

print(int(dp[m][n]))
