#!/usr/bin/env python
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = {}
for i in range(n + 1):
	DP[i] = n
DP[0] = 0
for cost in c:
	for i in range(cost, n + 1):
		DP[i] = min(DP[i], DP[i - cost] + 1)
print(DP[n])
 n, m = list(map(int, input().split())) n list(map(int, input().split())) list 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 DP = {} DP {} for i in range(n + 1):
	DP[i] = n i range(n + 1) range n + 1 n 1 DP[i] = n DP[i] DP i n DP[0] = 0 DP[0] DP 0 0 for cost in c:
	for i in range(cost, n + 1):
		DP[i] = min(DP[i], DP[i - cost] + 1) cost c for i in range(cost, n + 1):
		DP[i] = min(DP[i], DP[i - cost] + 1) i range(cost, n + 1) range cost n + 1 n 1 DP[i] = min(DP[i], DP[i - cost] + 1) DP[i] DP i min(DP[i], DP[i - cost] + 1) min DP[i] DP i DP[i - cost] + 1 DP[i - cost] DP i - cost i cost 1 print(DP[n]) print DP[n] DP n n, m = list(map(int, input().split())) list(map(int, input().split())) n c = list(map(int, input().split())) list(map(int, input().split())) c DP = {} {} DP m = list(map(int, input().split())) list(map(int, input().split())) m
#!/usr/bin/env python
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = {}
for i in range(n + 1):
	DP[i] = n
DP[0] = 0
for cost in c:
	for i in range(cost, n + 1):
		DP[i] = min(DP[i], DP[i - cost] + 1)
print(DP[n])

