n, m = map(int, input().split())
c = [0] + list(map(int, input().split()))

INF = 1 << 29

# dp table 
NMAX = 500000
dp = [INF] * (NMAX + 1)

dp[0] = 0

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

print(dp[n])

 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m c = [0] + list(map(int, input().split())) c [0] + list(map(int, input().split())) [0] 0 list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split INF = 1 << 29 INF 1 << 29 1 29 NMAX = 500000 NMAX 500000 dp = [INF] * (NMAX + 1) dp [INF] * (NMAX + 1) [INF] INF NMAX + 1 NMAX 1 dp[0] = 0 dp[0] dp 0 0 for i in range(1, m + 1):
	for j in range(c[i], n + 1):
		dp[j] = min(dp[j], dp[j-c[i]] + 1) i range(1, m + 1) range 1 m + 1 m 1 for j in range(c[i], n + 1):
		dp[j] = min(dp[j], dp[j-c[i]] + 1) j range(c[i], n + 1) range c[i] c i n + 1 n 1 dp[j] = min(dp[j], dp[j-c[i]] + 1) dp[j] dp j min(dp[j], dp[j-c[i]] + 1) min dp[j] dp j dp[j-c[i]] + 1 dp[j-c[i]] dp j-c[i] j c[i] c i 1 print(dp[n]) print dp[n] dp n n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m dp = [INF] * (NMAX + 1) [INF] * (NMAX + 1) dp NMAX = 500000 500000 NMAX INF = 1 << 29 1 << 29 INF c = [0] + list(map(int, input().split())) [0] + list(map(int, input().split())) c
n, m = map(int, input().split())
c = [0] + list(map(int, input().split()))

INF = 1 << 29

# dp table 
NMAX = 500000
dp = [INF] * (NMAX + 1)

dp[0] = 0

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

print(dp[n])


