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

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

int minc(int c1, int c2);


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

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

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

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

	return 0;
}

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