INF = 1e5
n, m = list(map(int, input().split()))
C = list(map(int, input().split()))
dp = [[INF] * (n + 1) for _ in range(m)] 
for i in range(m):
    dp[i][0] = 0
for j in range(1 + n):
    dp[0][j] = j
from itertools import product
for i, j in product(range(1, m), range(1, n + 1)):
    dp[i][j] = min(dp[i][j], dp[i - 1][j])
    if 0 <= j - C[i]:
        dp[i][j] = min(dp[i][j], dp[i][j - C[i]] + 1)

print(dp[i][j]) INF = 1e5 INF 1e5 n, m = list(map(int, input().split())) n list(map(int, input().split())) list 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] * (n + 1) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [INF] * (n + 1) [INF] INF n + 1 n 1 dp = [[INF] * (n + 1) for _ in range(m)] dp [[INF] * (n + 1) for _ in range(m)] for i in range(m):
    dp[i][0] = 0 i range(m) range m dp[i][0] = 0 dp[i][0] [i] dp i 0 0 for j in range(1 + n):
    dp[0][j] = j j range(1 + n) range 1 + n 1 n dp[0][j] = j dp[0][j] [0] dp 0 j j from itertools import product for i, j in product(range(1, m), range(1, n + 1)):
    dp[i][j] = min(dp[i][j], dp[i - 1][j])
    if 0 <= j - C[i]:
        dp[i][j] = min(dp[i][j], dp[i][j - C[i]] + 1) i j product(range(1, m), range(1, n + 1)) product range(1, m) range 1 m range(1, n + 1) range 1 n + 1 n 1 dp[i][j] = min(dp[i][j], dp[i - 1][j]) dp[i][j] [i] dp i j min(dp[i][j], dp[i - 1][j]) min dp[i][j] [i] dp i j dp[i - 1][j] [i - 1] dp i - 1 i 1 j if 0 <= j - C[i]:
        dp[i][j] = min(dp[i][j], dp[i][j - C[i]] + 1) 0 <= j - C[i] 0 j - C[i] j C[i] C i dp[i][j] = min(dp[i][j], dp[i][j - C[i]] + 1) dp[i][j] [i] dp i j min(dp[i][j], dp[i][j - C[i]] + 1) min dp[i][j] [i] dp i j dp[i][j - C[i]] + 1 dp[i][j - C[i]] [i] dp i j - C[i] j C[i] C i 1 print(dp[i][j]) print dp[i][j] [i] dp i j C = list(map(int, input().split())) list(map(int, input().split())) C INF = 1e5 1e5 INF m = list(map(int, input().split())) list(map(int, input().split())) m n, m = list(map(int, input().split())) list(map(int, input().split())) n dp = [[INF] * (n + 1) for _ in range(m)] [[INF] * (n + 1) for _ in range(m)] dp
INF = 1e5
n, m = list(map(int, input().split()))
C = list(map(int, input().split()))
dp = [[INF] * (n + 1) for _ in range(m)] 
for i in range(m):
    dp[i][0] = 0
for j in range(1 + n):
    dp[0][j] = j
from itertools import product
for i, j in product(range(1, m), range(1, n + 1)):
    dp[i][j] = min(dp[i][j], dp[i - 1][j])
    if 0 <= j - C[i]:
        dp[i][j] = min(dp[i][j], dp[i][j - C[i]] + 1)

print(dp[i][j])
