n, m = map(int, input().split())
coins = list(map(int, input().split()))
coins.insert(0, 0)
inf = float('inf')
dps = [[inf for _ in range(n + 1)] for _ in range(m + 1)]
# for j in range(n + 1):
#     dps[0][j] = 0
for i in range(m + 1):
    dps[i][0] = 0

for i in range(1, m + 1):
    for j in range(1, n + 1):
        if i == 1:
            dps[i][j] = j // coins[i]
            continue
        if j >= coins[i]:
            dps[i][j] = min(dps[i][j - coins[i]] + 1,
                            dps[i - 1][j - coins[i]] + 1,
                            dps[i - 1][j])
        else:
            dps[i][j] = dps[i - 1][j]
print(dps[m][n])
 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m coins = list(map(int, input().split())) coins list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split coins.insert(0, 0) coins.insert coins insert 0 0 inf = float('inf') inf float('inf') float 'inf' [inf for _ in range(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) [inf for _ in range(n + 1)] dps = [[inf for _ in range(n + 1)] for _ in range(m + 1)] dps [[inf for _ in range(n + 1)] for _ in range(m + 1)] for i in range(m + 1):
    dps[i][0] = 0 i range(m + 1) range m + 1 m 1 dps[i][0] = 0 dps[i][0] [i] dps i 0 0 for i in range(1, m + 1):
    for j in range(1, n + 1):
        if i == 1:
            dps[i][j] = j // coins[i]
            continue
        if j >= coins[i]:
            dps[i][j] = min(dps[i][j - coins[i]] + 1,
                            dps[i - 1][j - coins[i]] + 1,
                            dps[i - 1][j])
        else:
            dps[i][j] = dps[i - 1][j] i range(1, m + 1) range 1 m + 1 m 1 for j in range(1, n + 1):
        if i == 1:
            dps[i][j] = j // coins[i]
            continue
        if j >= coins[i]:
            dps[i][j] = min(dps[i][j - coins[i]] + 1,
                            dps[i - 1][j - coins[i]] + 1,
                            dps[i - 1][j])
        else:
            dps[i][j] = dps[i - 1][j] j range(1, n + 1) range 1 n + 1 n 1 if i == 1:
            dps[i][j] = j // coins[i]
            continue
         i == 1 i 1 dps[i][j] = j // coins[i] dps[i][j] [i] dps i j j // coins[i] j coins[i] coins i continue if j >= coins[i]:
            dps[i][j] = min(dps[i][j - coins[i]] + 1,
                            dps[i - 1][j - coins[i]] + 1,
                            dps[i - 1][j])
        else:
            dps[i][j] = dps[i - 1][j] j >= coins[i] j coins[i] coins i dps[i][j] = min(dps[i][j - coins[i]] + 1,
                            dps[i - 1][j - coins[i]] + 1,
                            dps[i - 1][j]) dps[i][j] [i] dps i j min(dps[i][j - coins[i]] + 1,
                            dps[i - 1][j - coins[i]] + 1,
                            dps[i - 1][j]) min dps[i][j - coins[i]] + 1 dps[i][j - coins[i]] [i] dps i j - coins[i] j coins[i] coins i 1 dps[i - 1][j - coins[i]] + 1 dps[i - 1][j - coins[i]] [i - 1] dps i - 1 i 1 j - coins[i] j coins[i] coins i 1 dps[i - 1][j] [i - 1] dps i - 1 i 1 j dps[i][j] = dps[i - 1][j] dps[i][j] [i] dps i j dps[i - 1][j] [i - 1] dps i - 1 i 1 j print(dps[m][n]) print dps[m][n] [m] dps m n dps = [[inf for _ in range(n + 1)] for _ in range(m + 1)] [[inf for _ in range(n + 1)] for _ in range(m + 1)] dps n, m = map(int, input().split()) map(int, input().split()) n inf = float('inf') float('inf') inf m = map(int, input().split()) map(int, input().split()) m coins = list(map(int, input().split())) list(map(int, input().split())) coins
n, m = map(int, input().split())
coins = list(map(int, input().split()))
coins.insert(0, 0)
inf = float('inf')
dps = [[inf for _ in range(n + 1)] for _ in range(m + 1)]
# for j in range(n + 1):
#     dps[0][j] = 0
for i in range(m + 1):
    dps[i][0] = 0

for i in range(1, m + 1):
    for j in range(1, n + 1):
        if i == 1:
            dps[i][j] = j // coins[i]
            continue
        if j >= coins[i]:
            dps[i][j] = min(dps[i][j - coins[i]] + 1,
                            dps[i - 1][j - coins[i]] + 1,
                            dps[i - 1][j])
        else:
            dps[i][j] = dps[i - 1][j]
print(dps[m][n])

