from __future__ import division
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 = map(int, stdin.readline().strip().split())
    ds = map(int, stdin.readline().strip().split())
    print(solve(n, m, ds)) from __future__ import division 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] solve dp = [maxint] * (n + 1) dp [maxint] * (n + 1) [maxint] maxint n + 1 n 1 dp[0] = 0 dp[0] 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)

     i range(1, n + 1) range 1 n + 1 n 1 for j in range(m):
            if i >= ds[j]:
                dp[i] = min(dp[i], dp[i - ds[j]] + 1)

     j range(m) range m if i >= ds[j]:
                dp[i] = min(dp[i], dp[i - ds[j]] + 1)

     i >= ds[j] i ds[j] ds j dp[i] = min(dp[i], dp[i - ds[j]] + 1) dp[i] dp i min(dp[i], dp[i - ds[j]] + 1) min dp[i] dp i dp[i - ds[j]] + 1 dp[i - ds[j]] dp i - ds[j] i ds[j] ds j 1 return dp[n] dp[n] dp n n n m m ds ds if __name__ == '__main__':
    n, m = map(int, stdin.readline().strip().split())
    ds = map(int, stdin.readline().strip().split())
    print(solve(n, m, ds)) __name__ == '__main__' __name__ '__main__' n, m = map(int, stdin.readline().strip().split()) n map(int, stdin.readline().strip().split()) map int stdin.readline().strip().split() stdin.readline().strip().split stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip split m ds = map(int, stdin.readline().strip().split()) ds map(int, stdin.readline().strip().split()) map int stdin.readline().strip().split() stdin.readline().strip().split stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip split print(solve(n, m, ds)) print solve(n, m, ds) solve n m ds n, m = map(int, stdin.readline().strip().split()) map(int, stdin.readline().strip().split()) n m = map(int, stdin.readline().strip().split()) map(int, stdin.readline().strip().split()) m ds = map(int, stdin.readline().strip().split()) map(int, stdin.readline().strip().split()) ds 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] 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] solve
from __future__ import division
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 = map(int, stdin.readline().strip().split())
    ds = map(int, stdin.readline().strip().split())
    print(solve(n, m, ds))