#include <stdio.h>

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	int c[20];
	int dp[50001];
	for (int i = 0; i < m; i++) {
		scanf("%d", &c[i]);
	}
	dp[0] = 0;
	dp[1] = 1;
	for (int k = 2; k <= n; k++) {
		int min = 999999;
		//int mini = -1;
		for (int l = 0; l < m; l++) {
			if (k - c[l] >= 0) {
				if (min > dp[k - c[l]]) {
					min = dp[k - c[l]];
					//mini = l;
				}
			}
		}
		dp[k] = min + 1;
	}
	printf("%d\n", dp[n]);
	return 0;
}
