import sys

n, m = map(int, sys.stdin.readline().strip().split())
c = list(map(int, sys.stdin.readline().strip().split()))

dp = [float("inf") for _ in range(n+1)]
dp[0] = 0

for i in range(n+1):
    for c_i in c:
        if i - c_i >= 0:
            dp[i] = min(dp[i], dp[i - c_i] + 1)

print(dp[n]) import sys sys n, m = map(int, sys.stdin.readline().strip().split()) n map(int, sys.stdin.readline().strip().split()) map int sys.stdin.readline().strip().split() sys.stdin.readline().strip().split sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip split m c = list(map(int, sys.stdin.readline().strip().split())) c list(map(int, sys.stdin.readline().strip().split())) list map(int, sys.stdin.readline().strip().split()) map int sys.stdin.readline().strip().split() sys.stdin.readline().strip().split sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip split float("inf") for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) float("inf") float "inf" dp = [float("inf") for _ in range(n+1)] dp [float("inf") for _ in range(n+1)] dp[0] = 0 dp[0] dp 0 0 for i in range(n+1):
    for c_i in c:
        if i - c_i >= 0:
            dp[i] = min(dp[i], dp[i - c_i] + 1) i range(n+1) range n+1 n 1 for c_i in c:
        if i - c_i >= 0:
            dp[i] = min(dp[i], dp[i - c_i] + 1) c_i c if i - c_i >= 0:
            dp[i] = min(dp[i], dp[i - c_i] + 1) i - c_i >= 0 i - c_i i c_i 0 dp[i] = min(dp[i], dp[i - c_i] + 1) dp[i] dp i min(dp[i], dp[i - c_i] + 1) min dp[i] dp i dp[i - c_i] + 1 dp[i - c_i] dp i - c_i i c_i 1 print(dp[n]) print dp[n] dp n dp = [float("inf") for _ in range(n+1)] [float("inf") for _ in range(n+1)] dp c = list(map(int, sys.stdin.readline().strip().split())) list(map(int, sys.stdin.readline().strip().split())) c n, m = map(int, sys.stdin.readline().strip().split()) map(int, sys.stdin.readline().strip().split()) n m = map(int, sys.stdin.readline().strip().split()) map(int, sys.stdin.readline().strip().split()) m
import sys

n, m = map(int, sys.stdin.readline().strip().split())
c = list(map(int, sys.stdin.readline().strip().split()))

dp = [float("inf") for _ in range(n+1)]
dp[0] = 0

for i in range(n+1):
    for c_i in c:
        if i - c_i >= 0:
            dp[i] = min(dp[i], dp[i - c_i] + 1)

print(dp[n])
