
if __name__ == '__main__':
	n = input().split()
	c = input().split()
	dp = [50000] * (int(n[0]) + 1)

	for i in range(int(n[1])):
		if int(c[i]) > int(n[0]):
			continue
		dp[int(c[i])] = 1
		for j in range(int(n[0])):
			if int(c[i])+j > int(n[0]):
				break;
			if dp[j] != 50000:
				dp[int(c[i])+j] = min(dp[int(c[i])+j], dp[j]+1)

	print (dp[int(n[0])])

 if __name__ == '__main__':
	n = input().split()
	c = input().split()
	dp = [50000] * (int(n[0]) + 1)

	for i in range(int(n[1])):
		if int(c[i]) > int(n[0]):
			continue
		dp[int(c[i])] = 1
		for j in range(int(n[0])):
			if int(c[i])+j > int(n[0]):
				break;
			if dp[j] != 50000:
				dp[int(c[i])+j] = min(dp[int(c[i])+j], dp[j]+1)

	print (dp[int(n[0])]) __name__ == '__main__' __name__ '__main__' n = input().split() n input().split() ().split () input split c = input().split() c input().split() ().split () input split dp = [50000] * (int(n[0]) + 1) dp [50000] * (int(n[0]) + 1) [50000] 50000 int(n[0]) + 1 int(n[0]) int n[0] n 0 1 for i in range(int(n[1])):
		if int(c[i]) > int(n[0]):
			continue
		dp[int(c[i])] = 1
		for j in range(int(n[0])):
			if int(c[i])+j > int(n[0]):
				break;
			if dp[j] != 50000:
				dp[int(c[i])+j] = min(dp[int(c[i])+j], dp[j]+1)

	 i range(int(n[1])) range int(n[1]) int n[1] n 1 if int(c[i]) > int(n[0]):
			continue
		 int(c[i]) > int(n[0]) int(c[i]) int c[i] c i int(n[0]) int n[0] n 0 continue dp[int(c[i])] = 1 dp[int(c[i])] dp int(c[i]) int c[i] c i 1 for j in range(int(n[0])):
			if int(c[i])+j > int(n[0]):
				break;
			if dp[j] != 50000:
				dp[int(c[i])+j] = min(dp[int(c[i])+j], dp[j]+1)

	 j range(int(n[0])) range int(n[0]) int n[0] n 0 if int(c[i])+j > int(n[0]):
				break;
			 int(c[i])+j > int(n[0]) int(c[i])+j int(c[i]) int c[i] c i j int(n[0]) int n[0] n 0 break if dp[j] != 50000:
				dp[int(c[i])+j] = min(dp[int(c[i])+j], dp[j]+1)

	 dp[j] != 50000 dp[j] dp j 50000 dp[int(c[i])+j] = min(dp[int(c[i])+j], dp[j]+1) dp[int(c[i])+j] dp int(c[i])+j int(c[i]) int c[i] c i j min(dp[int(c[i])+j], dp[j]+1) min dp[int(c[i])+j] dp int(c[i])+j int(c[i]) int c[i] c i j dp[j]+1 dp[j] dp j 1 print (dp[int(n[0])]) print dp[int(n[0])] dp int(n[0]) int n[0] n 0 dp = [50000] * (int(n[0]) + 1) [50000] * (int(n[0]) + 1) dp n = input().split() input().split() n c = input().split() input().split() c

if __name__ == '__main__':
	n = input().split()
	c = input().split()
	dp = [50000] * (int(n[0]) + 1)

	for i in range(int(n[1])):
		if int(c[i]) > int(n[0]):
			continue
		dp[int(c[i])] = 1
		for j in range(int(n[0])):
			if int(c[i])+j > int(n[0]):
				break;
			if dp[j] != 50000:
				dp[int(c[i])+j] = min(dp[int(c[i])+j], dp[j]+1)

	print (dp[int(n[0])])


