// AOJ DPL_1_A Coin Changing Problem
// 2018.5.9 bal4u

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

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF 0x33333333

int c[22];
int dp[50005];

int main()
{
	int n, m, i, j;

	n = in(), m = in();
	for (i = 1; i <= m; i++) c[i] = in();
	
	memset(dp, INF, sizeof(dp));
	dp[0] = 0;
	
	for (i = 1; i <= m; i++) for (j = 0; j+c[i] <= n; j++) {
		int x = dp[j]+1;
		if (x < dp[j+c[i]]) dp[j+c[i]] = x;
	}
	printf("%d\n", dp[n]);
	return 0;
}

