#include <stdio.h>
#include <stdlib.h>
#define INF 99999999
void init(int *c, int *s, int n)
{
	int i;
	c[0] = 0;
	for(i = 1; i < n; i++)
		c[i] = INF;

	for(i = 0; i < n; i++)
		s[i] = -1;
}

int min(int x, int y){return x<y?x:y;}

int main()
{
	int n, m, i, j, save;
	scanf("%d %d" ,&n ,&m);
	int *d = (int *)malloc(m*sizeof(int));
	int *c = (int *)malloc((n+1)*sizeof(int));
	int *s = (int *)malloc((n+1)*sizeof(int));
	for(i = 0; i < m; i++)
		scanf("%d" ,&d[i]);

	init(c, s, n+1);

	for(i = 0; i < m; i++)
	{
		for(j = d[i]; j <= n; j++)
		{
			save = c[j];
			c[j] = min(c[j], c[j-d[i]] + 1);
			if(c[j] != save) s[j] = d[i];
		}
	}		

	printf("%d\n" ,c[n]);
	return 0;
}