# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
n, m = inpl()
C = sorted(inpl())
DP = list(range(n+1))

for c in C[1:]:
    for i in range(n-c+1):
        if DP[i] + 1 < DP[i+c]:
            DP[i+c] = DP[i] + 1
            
print(DP[-1]) def inpl(): return list(map(int, input().split())) inpl n, m = inpl() n inpl() inpl m C = sorted(inpl()) C sorted(inpl()) sorted inpl() inpl DP = list(range(n+1)) DP list(range(n+1)) list range(n+1) range n+1 n 1 for c in C[1:]:
    for i in range(n-c+1):
        if DP[i] + 1 < DP[i+c]:
            DP[i+c] = DP[i] + 1
             c C[1:] C 1: 1 for i in range(n-c+1):
        if DP[i] + 1 < DP[i+c]:
            DP[i+c] = DP[i] + 1
             i range(n-c+1) range n-c+1 n-c n c 1 if DP[i] + 1 < DP[i+c]:
            DP[i+c] = DP[i] + 1
             DP[i] + 1 < DP[i+c] DP[i] + 1 DP[i] DP i 1 DP[i+c] DP i+c i c DP[i+c] = DP[i] + 1 DP[i+c] DP i+c i c DP[i] + 1 DP[i] DP i 1 print(DP[-1]) print DP[-1] DP -1 def inpl(): return list(map(int, input().split())) def inpl(): return list(map(int, input().split())) inpl n, m = inpl() inpl() n m = inpl() inpl() m DP = list(range(n+1)) list(range(n+1)) DP C = sorted(inpl()) sorted(inpl()) C
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
n, m = inpl()
C = sorted(inpl())
DP = list(range(n+1))

for c in C[1:]:
    for i in range(n-c+1):
        if DP[i] + 1 < DP[i+c]:
            DP[i+c] = DP[i] + 1
            
print(DP[-1])
