n, m = map(int, input().split())
*c, = map(int, input().split())
c.sort()
dp = [2**32 for _ in range(n+1)]
for i in range(n+1):
    dp[i] = i
for i in range(1, m):
    for j in range(n+1):
        if (j-c[i]) >= 0:
            dp[j] = min([
                dp[j],
                dp[j-c[i]]+1
            ])
        else:
            dp[j] = dp[j]
print(dp[n])
 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m *c, = map(int, input().split()) *c c map(int, input().split()) map int input().split() ().split () input split c.sort() c.sort c sort 2**32 for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) 2**32 2 32 dp = [2**32 for _ in range(n+1)] dp [2**32 for _ in range(n+1)] for i in range(n+1):
    dp[i] = i i range(n+1) range n+1 n 1 dp[i] = i dp[i] dp i i for i in range(1, m):
    for j in range(n+1):
        if (j-c[i]) >= 0:
            dp[j] = min([
                dp[j],
                dp[j-c[i]]+1
            ])
        else:
            dp[j] = dp[j] i range(1, m) range 1 m for j in range(n+1):
        if (j-c[i]) >= 0:
            dp[j] = min([
                dp[j],
                dp[j-c[i]]+1
            ])
        else:
            dp[j] = dp[j] j range(n+1) range n+1 n 1 if (j-c[i]) >= 0:
            dp[j] = min([
                dp[j],
                dp[j-c[i]]+1
            ])
        else:
            dp[j] = dp[j] (j-c[i]) >= 0 j-c[i] j c[i] c i 0 dp[j] = min([
                dp[j],
                dp[j-c[i]]+1
            ]) dp[j] dp j min([
                dp[j],
                dp[j-c[i]]+1
            ]) min [
                dp[j],
                dp[j-c[i]]+1
            ] dp[j] dp j dp[j-c[i]]+1 dp[j-c[i]] dp j-c[i] j c[i] c i 1 dp[j] = dp[j] dp[j] dp j dp[j] dp j print(dp[n]) print dp[n] dp n n, m = map(int, input().split()) map(int, input().split()) n dp = [2**32 for _ in range(n+1)] [2**32 for _ in range(n+1)] dp m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
*c, = map(int, input().split())
c.sort()
dp = [2**32 for _ in range(n+1)]
for i in range(n+1):
    dp[i] = i
for i in range(1, m):
    for j in range(n+1):
        if (j-c[i]) >= 0:
            dp[j] = min([
                dp[j],
                dp[j-c[i]]+1
            ])
        else:
            dp[j] = dp[j]
print(dp[n])

