def smaller(x, y):
	if x < y: return x
	return y

N, M = map(int, input().split())
coins = list(map(int, input().split()))
dp = []
for i in range(0, N+1):
	dp.append(100000)
dp[0] = 0
for i in range(0, N):
	for j in range(0, M):
		if i+coins[j] <= N:
			dp[i+coins[j]] = smaller(dp[i]+1, dp[i+coins[j]])
print(dp[N]) def smaller(x, y):
	if x < y: return x
	return y smaller if x < y: return x
	 x < y x y return y y x x y y N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M coins = list(map(int, input().split())) coins list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split dp = [] dp [] for i in range(0, N+1):
	dp.append(100000) i range(0, N+1) range 0 N+1 N 1 dp.append(100000) dp.append dp append 100000 dp[0] = 0 dp[0] dp 0 0 for i in range(0, N):
	for j in range(0, M):
		if i+coins[j] <= N:
			dp[i+coins[j]] = smaller(dp[i]+1, dp[i+coins[j]]) i range(0, N) range 0 N for j in range(0, M):
		if i+coins[j] <= N:
			dp[i+coins[j]] = smaller(dp[i]+1, dp[i+coins[j]]) j range(0, M) range 0 M if i+coins[j] <= N:
			dp[i+coins[j]] = smaller(dp[i]+1, dp[i+coins[j]]) i+coins[j] <= N i+coins[j] i coins[j] coins j N dp[i+coins[j]] = smaller(dp[i]+1, dp[i+coins[j]]) dp[i+coins[j]] dp i+coins[j] i coins[j] coins j smaller(dp[i]+1, dp[i+coins[j]]) smaller dp[i]+1 dp[i] dp i 1 dp[i+coins[j]] dp i+coins[j] i coins[j] coins j print(dp[N]) print dp[N] dp N def smaller(x, y):
	if x < y: return x
	return y def smaller(x, y):
	if x < y: return x
	return y smaller coins = list(map(int, input().split())) list(map(int, input().split())) coins dp = [] [] dp N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M
def smaller(x, y):
	if x < y: return x
	return y

N, M = map(int, input().split())
coins = list(map(int, input().split()))
dp = []
for i in range(0, N+1):
	dp.append(100000)
dp[0] = 0
for i in range(0, N):
	for j in range(0, M):
		if i+coins[j] <= N:
			dp[i+coins[j]] = smaller(dp[i]+1, dp[i+coins[j]])
print(dp[N])
