if __name__ == '__main__':
	n, m = map(int, input().split())
	coin_list = list(map(int, input().split()))
	dp = [50000] * (n + 1)
	dp[0] = 0

	for coin in coin_list:
		for i in range(n - coin + 1):
			if dp[i + coin] > dp[i] + 1:
				dp[i + coin] = dp[i] + 1

	print(dp[-1]) if __name__ == '__main__':
	n, m = map(int, input().split())
	coin_list = list(map(int, input().split()))
	dp = [50000] * (n + 1)
	dp[0] = 0

	for coin in coin_list:
		for i in range(n - coin + 1):
			if dp[i + coin] > dp[i] + 1:
				dp[i + coin] = dp[i] + 1

	print(dp[-1]) __name__ == '__main__' __name__ '__main__' n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m coin_list = list(map(int, input().split())) coin_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split dp = [50000] * (n + 1) dp [50000] * (n + 1) [50000] 50000 n + 1 n 1 dp[0] = 0 dp[0] dp 0 0 for coin in coin_list:
		for i in range(n - coin + 1):
			if dp[i + coin] > dp[i] + 1:
				dp[i + coin] = dp[i] + 1

	 coin coin_list for i in range(n - coin + 1):
			if dp[i + coin] > dp[i] + 1:
				dp[i + coin] = dp[i] + 1

	 i range(n - coin + 1) range n - coin + 1 n - coin n coin 1 if dp[i + coin] > dp[i] + 1:
				dp[i + coin] = dp[i] + 1

	 dp[i + coin] > dp[i] + 1 dp[i + coin] dp i + coin i coin dp[i] + 1 dp[i] dp i 1 dp[i + coin] = dp[i] + 1 dp[i + coin] dp i + coin i coin dp[i] + 1 dp[i] dp i 1 print(dp[-1]) print dp[-1] dp -1 dp = [50000] * (n + 1) [50000] * (n + 1) dp n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m coin_list = list(map(int, input().split())) list(map(int, input().split())) coin_list
if __name__ == '__main__':
	n, m = map(int, input().split())
	coin_list = list(map(int, input().split()))
	dp = [50000] * (n + 1)
	dp[0] = 0

	for coin in coin_list:
		for i in range(n - coin + 1):
			if dp[i + coin] > dp[i] + 1:
				dp[i + coin] = dp[i] + 1

	print(dp[-1])
