n, m = map(int, input().split())
coins = list(map(int, input().split()))
memo = [0] + [10**7] * n
for coin in coins:
    for i in range(coin, n+1):
        memo[i] = min(memo[i], memo[i-coin]+1)
print(memo[-1])
 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 memo = [0] + [10**7] * n memo [0] + [10**7] * n [0] 0 [10**7] * n [10**7] 10**7 10 7 n for coin in coins:
    for i in range(coin, n+1):
        memo[i] = min(memo[i], memo[i-coin]+1) coin coins for i in range(coin, n+1):
        memo[i] = min(memo[i], memo[i-coin]+1) i range(coin, n+1) range coin n+1 n 1 memo[i] = min(memo[i], memo[i-coin]+1) memo[i] memo i min(memo[i], memo[i-coin]+1) min memo[i] memo i memo[i-coin]+1 memo[i-coin] memo i-coin i coin 1 print(memo[-1]) print memo[-1] memo -1 n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m coins = list(map(int, input().split())) list(map(int, input().split())) coins memo = [0] + [10**7] * n [0] + [10**7] * n memo
n, m = map(int, input().split())
coins = list(map(int, input().split()))
memo = [0] + [10**7] * n
for coin in coins:
    for i in range(coin, n+1):
        memo[i] = min(memo[i], memo[i-coin]+1)
print(memo[-1])

