n,m = map(int,input().split())
C = sorted(map(int,input().split()))


T = [float("inf")]*(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(T[n]) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m C = sorted(map(int,input().split())) C sorted(map(int,input().split())) sorted map(int,input().split()) map int input().split() ().split () input split T = [float("inf")]*(n+1) T [float("inf")]*(n+1) [float("inf")] float("inf") float "inf" n+1 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(T[n]) print T[n] T n C = sorted(map(int,input().split())) sorted(map(int,input().split())) C T = [float("inf")]*(n+1) [float("inf")]*(n+1) T m = map(int,input().split()) map(int,input().split()) m n,m = map(int,input().split()) map(int,input().split()) n
n,m = map(int,input().split())
C = sorted(map(int,input().split()))


T = [float("inf")]*(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(T[n])