#include <stdio.h>          // printf(), scanf()

#define MAX_N 20
#define MAX_V 50000
#define min(a, b) ((a) < (b) ? (a) : (b))

static const int INF = 100000000;

int
main(int argc, char** argv)
{
	int c[MAX_N + 1];
	int t[MAX_V + 1];
	int v, n;
	int i, j;

	scanf("%d %d", &v, &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &c[i]);

	for (i = 1; i <= MAX_V; ++i)
		t[i] = INF;

	t[0] = 0;
	for (i = 0; i < n; ++i)
	{
		for (j = c[i]; j <= v; ++j)
			t[j] = min(t[j], t[j - c[i]] + 1);
	}

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