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

dp = [[10**8]*(n+1) for i in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for j in range(n+1):
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
        if j + c[i] <= n:
            dp[i+1][j+c[i]] = min(dp[i+1][j]+1, dp[i+1][j+c[i]])

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

dp = [[10**8]*(n+1) for i in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for j in range(n+1):
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
        if j + c[i] <= n:
            dp[i+1][j+c[i]] = min(dp[i+1][j]+1, dp[i+1][j+c[i]])

print(dp[m][n])

