import sys

inf = 1<<30

def solve():
    n, m = map(int, input().split())
    c = [int(i) for i in input().split()]
    c.sort()

    dp = [inf] * (n + 1)
    dp[0] = 0

    for i in range(1, n + 1):
        for cj in c:
            if i - cj < 0:
                break
            dp[i] = min(dp[i], dp[i - cj] + 1)

    ans = dp[n]
    print(ans)

if __name__ == '__main__':
    solve() import sys sys inf = 1<<30 inf 1<<30 1 30 def solve():
    n, m = map(int, input().split())
    c = [int(i) for i in input().split()]
    c.sort()

    dp = [inf] * (n + 1)
    dp[0] = 0

    for i in range(1, n + 1):
        for cj in c:
            if i - cj < 0:
                break
            dp[i] = min(dp[i], dp[i - cj] + 1)

    ans = dp[n]
    print(ans) solve n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i c = [int(i) for i in input().split()] c [int(i) for i in input().split()] c.sort() c.sort c sort dp = [inf] * (n + 1) dp [inf] * (n + 1) [inf] inf n + 1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(1, n + 1):
        for cj in c:
            if i - cj < 0:
                break
            dp[i] = min(dp[i], dp[i - cj] + 1)

     i range(1, n + 1) range 1 n + 1 n 1 for cj in c:
            if i - cj < 0:
                break
            dp[i] = min(dp[i], dp[i - cj] + 1)

     cj c if i - cj < 0:
                break
             i - cj < 0 i - cj i cj 0 break dp[i] = min(dp[i], dp[i - cj] + 1) dp[i] dp i min(dp[i], dp[i - cj] + 1) min dp[i] dp i dp[i - cj] + 1 dp[i - cj] dp i - cj i cj 1 ans = dp[n] ans dp[n] dp n print(ans) print ans if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    n, m = map(int, input().split())
    c = [int(i) for i in input().split()]
    c.sort()

    dp = [inf] * (n + 1)
    dp[0] = 0

    for i in range(1, n + 1):
        for cj in c:
            if i - cj < 0:
                break
            dp[i] = min(dp[i], dp[i - cj] + 1)

    ans = dp[n]
    print(ans) def solve():
    n, m = map(int, input().split())
    c = [int(i) for i in input().split()]
    c.sort()

    dp = [inf] * (n + 1)
    dp[0] = 0

    for i in range(1, n + 1):
        for cj in c:
            if i - cj < 0:
                break
            dp[i] = min(dp[i], dp[i - cj] + 1)

    ans = dp[n]
    print(ans) solve inf = 1<<30 1<<30 inf
import sys

inf = 1<<30

def solve():
    n, m = map(int, input().split())
    c = [int(i) for i in input().split()]
    c.sort()

    dp = [inf] * (n + 1)
    dp[0] = 0

    for i in range(1, n + 1):
        for cj in c:
            if i - cj < 0:
                break
            dp[i] = min(dp[i], dp[i - cj] + 1)

    ans = dp[n]
    print(ans)

if __name__ == '__main__':
    solve()