N, M = map(int, input().split())
C = list(map(int, input().split()))

# dp[i][j] := C[i]までのコインを使ってj円を支払うときのコインの最小枚数
dp = [[10 ** 9] * (N+1) for _ in range(M+1)]
dp[0][0] = 0
for i in range(1,M+1):
    for j in range(N+1):
        if j - C[i-1] >= 0:
            dp[i][j] = min(dp[i][j-C[i-1]]+1, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]

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 ** 9] * (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) [10 ** 9] * (N+1) [10 ** 9] 10 ** 9 10 9 N+1 N 1 dp = [[10 ** 9] * (N+1) for _ in range(M+1)] dp [[10 ** 9] * (N+1) for _ in range(M+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(1,M+1):
    for j in range(N+1):
        if j - C[i-1] >= 0:
            dp[i][j] = min(dp[i][j-C[i-1]]+1, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j] i range(1,M+1) range 1 M+1 M 1 for j in range(N+1):
        if j - C[i-1] >= 0:
            dp[i][j] = min(dp[i][j-C[i-1]]+1, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j] j range(N+1) range N+1 N 1 if j - C[i-1] >= 0:
            dp[i][j] = min(dp[i][j-C[i-1]]+1, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j] j - C[i-1] >= 0 j - C[i-1] j C[i-1] C i-1 i 1 0 dp[i][j] = min(dp[i][j-C[i-1]]+1, dp[i-1][j]) dp[i][j] [i] dp i j min(dp[i][j-C[i-1]]+1, dp[i-1][j]) min dp[i][j-C[i-1]]+1 dp[i][j-C[i-1]] [i] dp i j-C[i-1] j C[i-1] C i-1 i 1 1 dp[i-1][j] [i-1] dp i-1 i 1 j dp[i][j] = dp[i-1][j] dp[i][j] [i] dp i j dp[i-1][j] [i-1] dp i-1 i 1 j print(dp[M][N]) print dp[M][N] [M] dp M N N, M = map(int, input().split()) map(int, input().split()) N C = list(map(int, input().split())) list(map(int, input().split())) C M = map(int, input().split()) map(int, input().split()) M dp = [[10 ** 9] * (N+1) for _ in range(M+1)] [[10 ** 9] * (N+1) for _ in range(M+1)] dp
N, M = map(int, input().split())
C = list(map(int, input().split()))

# dp[i][j] := C[i]までのコインを使ってj円を支払うときのコインの最小枚数
dp = [[10 ** 9] * (N+1) for _ in range(M+1)]
dp[0][0] = 0
for i in range(1,M+1):
    for j in range(N+1):
        if j - C[i-1] >= 0:
            dp[i][j] = min(dp[i][j-C[i-1]]+1, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[M][N])

