inf = 10**9+7
mod = 10**9+7
n, m = map(int, input().split())
c = list(map(int, input().split()))
dp = [[inf for j in range(n+1)]for i in range(m+1)] #i番目まででj払う時に必要な最小枚数
dp[0][0] = 0
for i in range(m):
    dp[i+1][0] = 0
    for j in range(n):
        if j+1-c[i] >= 0:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-c[i]]+1, dp[i+1][j+1-c[i]]+1)
        else:
            dp[i+1][j+1] = dp[i][j+1]
print(dp[m][n]) inf = 10**9+7 inf 10**9+7 10**9 10 9 7 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 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 [inf for j in range(n+1)]for i in range(m+1) for i in range(m+1) i range(m+1) range m+1 m 1 for i in range(m+1) [inf for j in range(n+1)] dp = [[inf for j in range(n+1)]for i in range(m+1)] dp [[inf for j in range(n+1)]for i in range(m+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    dp[i+1][0] = 0
    for j in range(n):
        if j+1-c[i] >= 0:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-c[i]]+1, dp[i+1][j+1-c[i]]+1)
        else:
            dp[i+1][j+1] = dp[i][j+1] i range(m) range m dp[i+1][0] = 0 dp[i+1][0] [i+1] dp i+1 i 1 0 0 for j in range(n):
        if j+1-c[i] >= 0:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-c[i]]+1, dp[i+1][j+1-c[i]]+1)
        else:
            dp[i+1][j+1] = dp[i][j+1] j range(n) range n if j+1-c[i] >= 0:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-c[i]]+1, dp[i+1][j+1-c[i]]+1)
        else:
            dp[i+1][j+1] = dp[i][j+1] j+1-c[i] >= 0 j+1-c[i] j+1 j 1 c[i] c i 0 dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-c[i]]+1, dp[i+1][j+1-c[i]]+1) dp[i+1][j+1] [i+1] dp i+1 i 1 j+1 j 1 min(dp[i][j+1], dp[i][j+1-c[i]]+1, dp[i+1][j+1-c[i]]+1) min dp[i][j+1] [i] dp i j+1 j 1 dp[i][j+1-c[i]]+1 dp[i][j+1-c[i]] [i] dp i j+1-c[i] j+1 j 1 c[i] c i 1 dp[i+1][j+1-c[i]]+1 dp[i+1][j+1-c[i]] [i+1] dp i+1 i 1 j+1-c[i] j+1 j 1 c[i] c i 1 dp[i+1][j+1] = dp[i][j+1] dp[i+1][j+1] [i+1] dp i+1 i 1 j+1 j 1 dp[i][j+1] [i] dp i j+1 j 1 print(dp[m][n]) print dp[m][n] [m] dp m n c = list(map(int, input().split())) list(map(int, input().split())) c inf = 10**9+7 10**9+7 inf m = map(int, input().split()) map(int, input().split()) m mod = 10**9+7 10**9+7 mod dp = [[inf for j in range(n+1)]for i in range(m+1)] [[inf for j in range(n+1)]for i in range(m+1)] dp n, m = map(int, input().split()) map(int, input().split()) n
inf = 10**9+7
mod = 10**9+7
n, m = map(int, input().split())
c = list(map(int, input().split()))
dp = [[inf for j in range(n+1)]for i in range(m+1)] #i番目まででj払う時に必要な最小枚数
dp[0][0] = 0
for i in range(m):
    dp[i+1][0] = 0
    for j in range(n):
        if j+1-c[i] >= 0:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-c[i]]+1, dp[i+1][j+1-c[i]]+1)
        else:
            dp[i+1][j+1] = dp[i][j+1]
print(dp[m][n])
