# n:yen, m:coins
n, m = map(int, input().split())

# list of coins
c = list(map(int, input().split()))

dp = [float("inf")] * (n + 1)
dp[0] = 0

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


print(dp[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 dp = [float("inf")] * (n + 1) dp [float("inf")] * (n + 1) [float("inf")] float("inf") float "inf" n + 1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(m):
    for j in range(n + 1):
        if dp[j] >= 0 and j + c[i] <= n:
            dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1) i range(m) range m for j in range(n + 1):
        if dp[j] >= 0 and j + c[i] <= n:
            dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1) j range(n + 1) range n + 1 n 1 if dp[j] >= 0 and j + c[i] <= n:
            dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1) dp[j] >= 0 and j + c[i] <= n dp[j] >= 0 dp[j] dp j 0 j + c[i] <= n j + c[i] j c[i] c i n dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1) dp[j + c[i]] dp j + c[i] j c[i] c i min(dp[j + c[i]], dp[j] + 1) min dp[j + c[i]] dp j + c[i] j c[i] c i dp[j] + 1 dp[j] dp j 1 print(dp[n]) print dp[n] dp n c = list(map(int, input().split())) list(map(int, input().split())) c n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m dp = [float("inf")] * (n + 1) [float("inf")] * (n + 1) dp
# n:yen, m:coins
n, m = map(int, input().split())

# list of coins
c = list(map(int, input().split()))

dp = [float("inf")] * (n + 1)
dp[0] = 0

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


print(dp[n])

