INF = 10 ** 20

n, m = map(int, input().split())
c_lst = list(map(int, input().split()))

dp = [INF for _ in range(n + 1)]
dp[0] = 0
for coin in c_lst:
  for price in range(coin, n + 1):
    dp[price] = min(dp[price], dp[price - coin] + 1)

print(dp[n]) INF = 10 ** 20 INF 10 ** 20 10 20 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m c_lst = list(map(int, input().split())) c_lst list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split INF for _ in range(n + 1) for _ in range(n + 1) _ range(n + 1) range n + 1 n 1 for _ in range(n + 1) INF dp = [INF for _ in range(n + 1)] dp [INF for _ in range(n + 1)] dp[0] = 0 dp[0] dp 0 0 for coin in c_lst:
  for price in range(coin, n + 1):
    dp[price] = min(dp[price], dp[price - coin] + 1) coin c_lst for price in range(coin, n + 1):
    dp[price] = min(dp[price], dp[price - coin] + 1) price range(coin, n + 1) range coin n + 1 n 1 dp[price] = min(dp[price], dp[price - coin] + 1) dp[price] dp price min(dp[price], dp[price - coin] + 1) min dp[price] dp price dp[price - coin] + 1 dp[price - coin] dp price - coin price coin 1 print(dp[n]) print dp[n] dp n m = map(int, input().split()) map(int, input().split()) m INF = 10 ** 20 10 ** 20 INF c_lst = list(map(int, input().split())) list(map(int, input().split())) c_lst n, m = map(int, input().split()) map(int, input().split()) n dp = [INF for _ in range(n + 1)] [INF for _ in range(n + 1)] dp
INF = 10 ** 20

n, m = map(int, input().split())
c_lst = list(map(int, input().split()))

dp = [INF for _ in range(n + 1)]
dp[0] = 0
for coin in c_lst:
  for price in range(coin, n + 1):
    dp[price] = min(dp[price], dp[price - coin] + 1)

print(dp[n])
