n,m = map(int, input().split())
C = list(map(int, input().split()))
inf = float("inf")
T = [inf for i in range(n+1)]
T[0] = 0

for i in range(m):
    for j in range(C[i], n+1):
        T[j] = min(T[j], T[j - C[i]] + 1)

print(str(T[n])) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split inf = float("inf") inf float("inf") float "inf" inf for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) inf T = [inf for i in range(n+1)] T [inf for i in range(n+1)] T[0] = 0 T[0] T 0 0 for i in range(m):
    for j in range(C[i], n+1):
        T[j] = min(T[j], T[j - C[i]] + 1) i range(m) range m for j in range(C[i], n+1):
        T[j] = min(T[j], T[j - C[i]] + 1) j range(C[i], n+1) range C[i] C i n+1 n 1 T[j] = min(T[j], T[j - C[i]] + 1) T[j] T j min(T[j], T[j - C[i]] + 1) min T[j] T j T[j - C[i]] + 1 T[j - C[i]] T j - C[i] j C[i] C i 1 print(str(T[n])) print str(T[n]) str T[n] T n n,m = map(int, input().split()) map(int, input().split()) n inf = float("inf") float("inf") inf T = [inf for i in range(n+1)] [inf for i in range(n+1)] T m = map(int, input().split()) map(int, input().split()) m C = list(map(int, input().split())) list(map(int, input().split())) C
n,m = map(int, input().split())
C = list(map(int, input().split()))
inf = float("inf")
T = [inf for i in range(n+1)]
T[0] = 0

for i in range(m):
    for j in range(C[i], n+1):
        T[j] = min(T[j], T[j - C[i]] + 1)

print(str(T[n]))