import heapq

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


def fsp(n, coins):
    paid = [False] * (n + 1)
    paid[0] = True
    queue = list((1, v) for v in coins)
    heapq.heapify(queue)
    while queue:
        num, value = heapq.heappop(queue)
        if paid[value]:
            continue
        paid[value] = True
        for c in coins:
            new_value = value + c
            # Because of link cost is constant 1, it is reliably shortest-path.
            if new_value == n:
                return num + 1
            elif new_value > n or paid[new_value]:
                continue
            heapq.heappush(queue, (num + 1, value + c))


print(fsp(n, coins)) import heapq heapq n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m coins = set(map(int, input().split())) coins set(map(int, input().split())) set map(int, input().split()) map int input().split() ().split () input split def fsp(n, coins):
    paid = [False] * (n + 1)
    paid[0] = True
    queue = list((1, v) for v in coins)
    heapq.heapify(queue)
    while queue:
        num, value = heapq.heappop(queue)
        if paid[value]:
            continue
        paid[value] = True
        for c in coins:
            new_value = value + c
            # Because of link cost is constant 1, it is reliably shortest-path.
            if new_value == n:
                return num + 1
            elif new_value > n or paid[new_value]:
                continue
            heapq.heappush(queue, (num + 1, value + c)) fsp paid = [False] * (n + 1) paid [False] * (n + 1) [False] False n + 1 n 1 paid[0] = True paid[0] paid 0 True queue = list((1, v) for v in coins) queue list((1, v) for v in coins) list (1, v) 1 v heapq.heapify(queue) heapq.heapify heapq heapify queue while queue:
        num, value = heapq.heappop(queue)
        if paid[value]:
            continue
        paid[value] = True
        for c in coins:
            new_value = value + c
            # Because of link cost is constant 1, it is reliably shortest-path.
            if new_value == n:
                return num + 1
            elif new_value > n or paid[new_value]:
                continue
            heapq.heappush(queue, (num + 1, value + c)) queue num, value = heapq.heappop(queue) num heapq.heappop(queue) heapq.heappop heapq heappop queue value if paid[value]:
            continue
         paid[value] paid value continue paid[value] = True paid[value] paid value True for c in coins:
            new_value = value + c
            # Because of link cost is constant 1, it is reliably shortest-path.
            if new_value == n:
                return num + 1
            elif new_value > n or paid[new_value]:
                continue
            heapq.heappush(queue, (num + 1, value + c)) c coins new_value = value + c new_value value + c value c if new_value == n:
                return num + 1
            elif new_value > n or paid[new_value]:
                continue
             new_value == n new_value n return num + 1 num + 1 num 1 elif new_value > n or paid[new_value]:
                continue
             new_value > n or paid[new_value] new_value > n new_value n paid[new_value] paid new_value continue heapq.heappush(queue, (num + 1, value + c)) heapq.heappush heapq heappush queue (num + 1, value + c) num + 1 num 1 value + c value c n n coins coins print(fsp(n, coins)) print fsp(n, coins) fsp n coins coins = set(map(int, input().split())) set(map(int, input().split())) coins def fsp(n, coins):
    paid = [False] * (n + 1)
    paid[0] = True
    queue = list((1, v) for v in coins)
    heapq.heapify(queue)
    while queue:
        num, value = heapq.heappop(queue)
        if paid[value]:
            continue
        paid[value] = True
        for c in coins:
            new_value = value + c
            # Because of link cost is constant 1, it is reliably shortest-path.
            if new_value == n:
                return num + 1
            elif new_value > n or paid[new_value]:
                continue
            heapq.heappush(queue, (num + 1, value + c)) def fsp(n, coins):
    paid = [False] * (n + 1)
    paid[0] = True
    queue = list((1, v) for v in coins)
    heapq.heapify(queue)
    while queue:
        num, value = heapq.heappop(queue)
        if paid[value]:
            continue
        paid[value] = True
        for c in coins:
            new_value = value + c
            # Because of link cost is constant 1, it is reliably shortest-path.
            if new_value == n:
                return num + 1
            elif new_value > n or paid[new_value]:
                continue
            heapq.heappush(queue, (num + 1, value + c)) fsp n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m
import heapq

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


def fsp(n, coins):
    paid = [False] * (n + 1)
    paid[0] = True
    queue = list((1, v) for v in coins)
    heapq.heapify(queue)
    while queue:
        num, value = heapq.heappop(queue)
        if paid[value]:
            continue
        paid[value] = True
        for c in coins:
            new_value = value + c
            # Because of link cost is constant 1, it is reliably shortest-path.
            if new_value == n:
                return num + 1
            elif new_value > n or paid[new_value]:
                continue
            heapq.heappush(queue, (num + 1, value + c))


print(fsp(n, coins))