n,m=map(int,input().split())
c=list(map(int,input().split()))
dp=[[i for i in range(n+1)] for _ in range(m+1)]
for i in range(1,m+1):
    for w in range(1,n+1):
        if c[i-1]>w:
            dp[i][w]=dp[i-1][w]
        else:
            dp[i][w]=min(dp[i][w-c[i-1]]+1,dp[i-1][w])
print(dp[m][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 [i for i in range(n+1)] for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [i for i in range(n+1)] dp=[[i for i in range(n+1)] for _ in range(m+1)] dp [[i for i in range(n+1)] for _ in range(m+1)] for i in range(1,m+1):
    for w in range(1,n+1):
        if c[i-1]>w:
            dp[i][w]=dp[i-1][w]
        else:
            dp[i][w]=min(dp[i][w-c[i-1]]+1,dp[i-1][w]) i range(1,m+1) range 1 m+1 m 1 for w in range(1,n+1):
        if c[i-1]>w:
            dp[i][w]=dp[i-1][w]
        else:
            dp[i][w]=min(dp[i][w-c[i-1]]+1,dp[i-1][w]) w range(1,n+1) range 1 n+1 n 1 if c[i-1]>w:
            dp[i][w]=dp[i-1][w]
        else:
            dp[i][w]=min(dp[i][w-c[i-1]]+1,dp[i-1][w]) c[i-1]>w c[i-1] c i-1 i 1 w dp[i][w]=dp[i-1][w] dp[i][w] [i] dp i w dp[i-1][w] [i-1] dp i-1 i 1 w dp[i][w]=min(dp[i][w-c[i-1]]+1,dp[i-1][w]) dp[i][w] [i] dp i w min(dp[i][w-c[i-1]]+1,dp[i-1][w]) min dp[i][w-c[i-1]]+1 dp[i][w-c[i-1]] [i] dp i w-c[i-1] w c[i-1] c i-1 i 1 1 dp[i-1][w] [i-1] dp i-1 i 1 w print(dp[m][n]) print dp[m][n] [m] dp m n n,m=map(int,input().split()) map(int,input().split()) n dp=[[i for i in range(n+1)] for _ in range(m+1)] [[i for i in range(n+1)] for _ in range(m+1)] dp 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())
c=list(map(int,input().split()))
dp=[[i for i in range(n+1)] for _ in range(m+1)]
for i in range(1,m+1):
    for w in range(1,n+1):
        if c[i-1]>w:
            dp[i][w]=dp[i-1][w]
        else:
            dp[i][w]=min(dp[i][w-c[i-1]]+1,dp[i-1][w])
print(dp[m][n])
