#include <stdio.h>
#include <stdlib.h>

int n, m, d[20], count[50001] = { 0 };

int minc(int c1, int c2);


int main()
{
	int i = 0, j;

	scanf("%d %d", &n, &m);
	while (i < m) {
		scanf("%d", &d[i]);
		if (d[i] != ' ')i++;
	}
	

	for (i = 1; i <= n; i++) {
		count[i] = i;
	}

	for (i = 1; i < m; i++) {
		for (j = 1; j <= n; j++) {
			if (j - d[i] >= 0) {
				count[j] = minc(count[j], count[j - d[i]] + 1);
			}
		}
	}
	
	printf("%d\n", count[n]);

	return 0;
}

int minc(int c1, int c2)
{
	return c1 < c2 ? c1 : c2;
}