n, m = map(int, input().split())
d = list(map(int, input().split()))

T = [50001]*(n+1)
T[0] = 0
for i in range(m):
    for j in range(d[i],n+1):
        T[j] = min(T[j], T[j-d[i]]+1)
print(T[n]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m d = list(map(int, input().split())) d list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split T = [50001]*(n+1) T [50001]*(n+1) [50001] 50001 n+1 n 1 T[0] = 0 T[0] T 0 0 for i in range(m):
    for j in range(d[i],n+1):
        T[j] = min(T[j], T[j-d[i]]+1) i range(m) range m for j in range(d[i],n+1):
        T[j] = min(T[j], T[j-d[i]]+1) j range(d[i],n+1) range d[i] d i n+1 n 1 T[j] = min(T[j], T[j-d[i]]+1) T[j] T j min(T[j], T[j-d[i]]+1) min T[j] T j T[j-d[i]]+1 T[j-d[i]] T j-d[i] j d[i] d i 1 print(T[n]) print T[n] T n T = [50001]*(n+1) [50001]*(n+1) T d = list(map(int, input().split())) list(map(int, input().split())) d 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())
d = list(map(int, input().split()))

T = [50001]*(n+1)
T[0] = 0
for i in range(m):
    for j in range(d[i],n+1):
        T[j] = min(T[j], T[j-d[i]]+1)
print(T[n])
