#!/usr/bin/env python3

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')


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

# dp[i] := ちょうどi円支払うときのコインの最小枚数

dp = [INF] * (n + 1)
dp[0] = 0

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

print(dp[n])
 from pprint import pprint import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline INF = float('inf') INF float('inf') float 'inf' 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 dp = [INF] * (n + 1) dp [INF] * (n + 1) [INF] INF n + 1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(n + 1):
    for c in coins:
        if i - c < 0:
            continue
        dp[i] = min(dp[i], dp[i-c] + 1) i range(n + 1) range n + 1 n 1 for c in coins:
        if i - c < 0:
            continue
        dp[i] = min(dp[i], dp[i-c] + 1) c coins if i - c < 0:
            continue
         i - c < 0 i - c i c 0 continue dp[i] = min(dp[i], dp[i-c] + 1) dp[i] dp i min(dp[i], dp[i-c] + 1) min dp[i] dp i dp[i-c] + 1 dp[i-c] dp i-c i c 1 print(dp[n]) print dp[n] dp n INF = float('inf') float('inf') INF dp = [INF] * (n + 1) [INF] * (n + 1) dp input = sys.stdin.buffer.readline sys.stdin.buffer.readline input n, m = map(int, input().split()) map(int, input().split()) n coins = list(map(int, input().split())) list(map(int, input().split())) coins m = map(int, input().split()) map(int, input().split()) m
#!/usr/bin/env python3

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')


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

# dp[i] := ちょうどi円支払うときのコインの最小枚数

dp = [INF] * (n + 1)
dp[0] = 0

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

print(dp[n])

