import os
from functools import lru_cache

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))


@lru_cache(maxsize=None)
def solve(n):
    if n == 0:
        return 0
    if n < 0:
        return IINF
    ret = IINF
    for c in C:
        ret = min(ret, solve(n - c) + 1)
    return ret


print(solve(N))
 import os os from functools import lru_cache import sys sys if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r") os.getenv("LOCAL") os.getenv os getenv "LOCAL" sys.stdin = open("_in.txt", "r") sys.stdin sys stdin open("_in.txt", "r") open "_in.txt" "r" sys.setrecursionlimit(2147483647) sys.setrecursionlimit sys setrecursionlimit 2147483647 INF = float("inf") INF float("inf") float "inf" IINF = 10 ** 18 IINF 10 ** 18 10 18 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 N, M = list(map(int, sys.stdin.readline().split())) N list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split M C = list(map(int, sys.stdin.readline().split())) C list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def solve(n):
    if n == 0:
        return 0
    if n < 0:
        return IINF
    ret = IINF
    for c in C:
        ret = min(ret, solve(n - c) + 1)
    return ret solve if n == 0:
        return 0
     n == 0 n 0 return 0 0 if n < 0:
        return IINF
     n < 0 n 0 return IINF IINF ret = IINF ret IINF for c in C:
        ret = min(ret, solve(n - c) + 1)
     c C ret = min(ret, solve(n - c) + 1) ret min(ret, solve(n - c) + 1) min ret solve(n - c) + 1 solve(n - c) solve n - c n c 1 return ret ret n n @lru_cache(maxsize=None) solve maxsize=None @lru_cache(maxsize=None) lru_cache maxsize=None maxsize None solve print(solve(N)) print solve(N) solve N IINF = 10 ** 18 10 ** 18 IINF M = list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) M INF = float("inf") float("inf") INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD C = list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) C N, M = list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) N def solve(n):
    if n == 0:
        return 0
    if n < 0:
        return IINF
    ret = IINF
    for c in C:
        ret = min(ret, solve(n - c) + 1)
    return ret def solve(n):
    if n == 0:
        return 0
    if n < 0:
        return IINF
    ret = IINF
    for c in C:
        ret = min(ret, solve(n - c) + 1)
    return ret solve
import os
from functools import lru_cache

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))


@lru_cache(maxsize=None)
def solve(n):
    if n == 0:
        return 0
    if n < 0:
        return IINF
    ret = IINF
    for c in C:
        ret = min(ret, solve(n - c) + 1)
    return ret


print(solve(N))

