from sys import stdin
readline = stdin.readline

payment, _ = map(int, readline().split())
coin = list(map(int, readline().split()))

dp = [float('inf')] * (payment + 1)
dp[0] = 0

for ci in coin:
    for pi in range(ci, len(dp)):
        if dp[pi] > dp[pi - ci] + 1:
            dp[pi] = dp[pi - ci] + 1
print(dp[-1]) from sys import stdin readline = stdin.readline readline stdin.readline stdin readline payment, _ = map(int, readline().split()) payment map(int, readline().split()) map int readline().split() ().split () readline split _ coin = list(map(int, readline().split())) coin list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split dp = [float('inf')] * (payment + 1) dp [float('inf')] * (payment + 1) [float('inf')] float('inf') float 'inf' payment + 1 payment 1 dp[0] = 0 dp[0] dp 0 0 for ci in coin:
    for pi in range(ci, len(dp)):
        if dp[pi] > dp[pi - ci] + 1:
            dp[pi] = dp[pi - ci] + 1 ci coin for pi in range(ci, len(dp)):
        if dp[pi] > dp[pi - ci] + 1:
            dp[pi] = dp[pi - ci] + 1 pi range(ci, len(dp)) range ci len(dp) len dp if dp[pi] > dp[pi - ci] + 1:
            dp[pi] = dp[pi - ci] + 1 dp[pi] > dp[pi - ci] + 1 dp[pi] dp pi dp[pi - ci] + 1 dp[pi - ci] dp pi - ci pi ci 1 dp[pi] = dp[pi - ci] + 1 dp[pi] dp pi dp[pi - ci] + 1 dp[pi - ci] dp pi - ci pi ci 1 print(dp[-1]) print dp[-1] dp -1 coin = list(map(int, readline().split())) list(map(int, readline().split())) coin readline = stdin.readline stdin.readline readline _ = map(int, readline().split()) map(int, readline().split()) _ payment, _ = map(int, readline().split()) map(int, readline().split()) payment dp = [float('inf')] * (payment + 1) [float('inf')] * (payment + 1) dp
from sys import stdin
readline = stdin.readline

payment, _ = map(int, readline().split())
coin = list(map(int, readline().split()))

dp = [float('inf')] * (payment + 1)
dp[0] = 0

for ci in coin:
    for pi in range(ci, len(dp)):
        if dp[pi] > dp[pi - ci] + 1:
            dp[pi] = dp[pi - ci] + 1
print(dp[-1])