import sys


if __name__ == "__main__":
    n, m = map(lambda x: int(x), input().split())
    coins = list(map(lambda x: int(x), input().split()))

    table = [sys.maxsize] * (n + 2)
    table[0] = 0
    for i in range(n + 1):
        for coin in coins:
            if (i + coin <= n):
                table[i + coin] = min(table[i + coin], table[i] + 1)

    print(table[n])
 import sys sys if __name__ == "__main__":
    n, m = map(lambda x: int(x), input().split())
    coins = list(map(lambda x: int(x), input().split()))

    table = [sys.maxsize] * (n + 2)
    table[0] = 0
    for i in range(n + 1):
        for coin in coins:
            if (i + coin <= n):
                table[i + coin] = min(table[i + coin], table[i] + 1)

    print(table[n]) __name__ == "__main__" __name__ "__main__" n, m = map(lambda x: int(x), input().split()) n map(lambda x: int(x), input().split()) map lambda x: int(x) int(x) int x x input().split() ().split () input split m coins = list(map(lambda x: int(x), input().split())) coins list(map(lambda x: int(x), input().split())) list map(lambda x: int(x), input().split()) map lambda x: int(x) int(x) int x x input().split() ().split () input split table = [sys.maxsize] * (n + 2) table [sys.maxsize] * (n + 2) [sys.maxsize] sys.maxsize sys maxsize n + 2 n 2 table[0] = 0 table[0] table 0 0 for i in range(n + 1):
        for coin in coins:
            if (i + coin <= n):
                table[i + coin] = min(table[i + coin], table[i] + 1)

     i range(n + 1) range n + 1 n 1 for coin in coins:
            if (i + coin <= n):
                table[i + coin] = min(table[i + coin], table[i] + 1)

     coin coins if (i + coin <= n):
                table[i + coin] = min(table[i + coin], table[i] + 1)

     i + coin <= n i + coin i coin n table[i + coin] = min(table[i + coin], table[i] + 1) table[i + coin] table i + coin i coin min(table[i + coin], table[i] + 1) min table[i + coin] table i + coin i coin table[i] + 1 table[i] table i 1 print(table[n]) print table[n] table n n, m = map(lambda x: int(x), input().split()) map(lambda x: int(x), input().split()) n m = map(lambda x: int(x), input().split()) map(lambda x: int(x), input().split()) m coins = list(map(lambda x: int(x), input().split())) list(map(lambda x: int(x), input().split())) coins table = [sys.maxsize] * (n + 2) [sys.maxsize] * (n + 2) table
import sys


if __name__ == "__main__":
    n, m = map(lambda x: int(x), input().split())
    coins = list(map(lambda x: int(x), input().split()))

    table = [sys.maxsize] * (n + 2)
    table[0] = 0
    for i in range(n + 1):
        for coin in coins:
            if (i + coin <= n):
                table[i + coin] = min(table[i + coin], table[i] + 1)

    print(table[n])

