from itertools import product

value, variety = map(int, input().split())
coins = list(map(int, input().split()))
dp = [float("inf") for _ in range(value + 1)]
dp[0] = 0
for (c,j) in product(coins,list(range(value + 1))):
    if c <= j:
        dp[j] = min(dp[j], dp[j - c] + 1)
    else:
        dp[j] = dp[j]
print(dp[value]) from itertools import product value, variety = map(int, input().split()) value map(int, input().split()) map int input().split() ().split () input split variety coins = list(map(int, input().split())) coins list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split float("inf") for _ in range(value + 1) for _ in range(value + 1) _ range(value + 1) range value + 1 value 1 for _ in range(value + 1) float("inf") float "inf" dp = [float("inf") for _ in range(value + 1)] dp [float("inf") for _ in range(value + 1)] dp[0] = 0 dp[0] dp 0 0 for (c,j) in product(coins,list(range(value + 1))):
    if c <= j:
        dp[j] = min(dp[j], dp[j - c] + 1)
    else:
        dp[j] = dp[j] (c,j) c j product(coins,list(range(value + 1))) product coins list(range(value + 1)) list range(value + 1) range value + 1 value 1 if c <= j:
        dp[j] = min(dp[j], dp[j - c] + 1)
    else:
        dp[j] = dp[j] c <= j c j dp[j] = min(dp[j], dp[j - c] + 1) dp[j] dp j min(dp[j], dp[j - c] + 1) min dp[j] dp j dp[j - c] + 1 dp[j - c] dp j - c j c 1 dp[j] = dp[j] dp[j] dp j dp[j] dp j print(dp[value]) print dp[value] dp value variety = map(int, input().split()) map(int, input().split()) variety coins = list(map(int, input().split())) list(map(int, input().split())) coins value, variety = map(int, input().split()) map(int, input().split()) value dp = [float("inf") for _ in range(value + 1)] [float("inf") for _ in range(value + 1)] dp
from itertools import product

value, variety = map(int, input().split())
coins = list(map(int, input().split()))
dp = [float("inf") for _ in range(value + 1)]
dp[0] = 0
for (c,j) in product(coins,list(range(value + 1))):
    if c <= j:
        dp[j] = min(dp[j], dp[j - c] + 1)
    else:
        dp[j] = dp[j]
print(dp[value])