

from sys import stdin, maxint



def solve(n, m, ds):

    dp = [maxint] * (n + 1)

    dp[0] = 0

    for i in range(1, n + 1):

        for j in range(m):

            if i >= ds[j]:

                dp[i] = min(dp[i], dp[i - ds[j]] + 1)



    return dp[n]



if __name__ == '__main__':

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

    ds = list(map(int, stdin.readline().strip().split()))

    print((solve(n, m, ds)))
"""

problem statment url: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A

"""





from sys import stdin, maxint



def solve(n, m, ds):

    dp = [maxint] * (n + 1)

    dp[0] = 0

    for i in range(m):

        for j in range(ds[i], n + 1):

            dp[j] = min(dp[j], dp[j - ds[i]] + 1)



    return dp[n]



if __name__ == '__main__':

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

    ds = list(map(int, stdin.readline().strip().split()))

    print((solve(n, m, ds)))
from sys import stdin, maxint


def solve(n, m, ds):
    dp = [maxint] * (n + 1)
    dp[0] = 0
    for i in range(1, n + 1):
        for j in range(m):
            if i >= ds[j]:
                dp[i] = min(dp[i], dp[i - ds[j]] + 1)
    return dp[n]


if __name__ == "__main__":
    n, m = list(map(int, stdin.readline().strip().split()))
    ds = list(map(int, stdin.readline().strip().split()))
    print((solve(n, m, ds)))

"""
problem statment url: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A
"""
from sys import stdin, maxint


def solve(n, m, ds):
    dp = [maxint] * (n + 1)
    dp[0] = 0
    for i in range(m):
        for j in range(ds[i], n + 1):
            dp[j] = min(dp[j], dp[j - ds[i]] + 1)
    return dp[n]


if __name__ == "__main__":
    n, m = list(map(int, stdin.readline().strip().split()))
    ds = list(map(int, stdin.readline().strip().split()))
    print((solve(n, m, ds)))

+""" +problem statment url: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A +""" -    for i in range(1, n + 1): -        for j in range(m): -            if i >= ds[j]: -                dp[i] = min(dp[i], dp[i - ds[j]] + 1) +    for i in range(m): +        for j in range(ds[i], n + 1): +            dp[j] = min(dp[j], dp[j - ds[i]] + 1)