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