#include<stdio.h>
#include<stdlib.h>
#define min(a, b) (a)<(b) ? (a) : (b)

int c[20];
int memo[50000][20] = { 0 };

int min_coin(int amount, int coinnum);

int main() {
	int n, m, i;
	scanf("%d %d", &n, &m);
	for (i = 0; i < m; i++) scanf("%d", &c[i]);
	printf("%d\n", min_coin(n, m - 1));
	return 0;
}

int min_coin(int amount, int coinnum) {
	if (memo[amount][coinnum] == 0) {
		if (amount < 0 || coinnum < 0) return 50001;
		else if (amount == c[coinnum]) return 1;
		else return memo[amount][coinnum] = min(min_coin(amount, coinnum - 1), min_coin(amount - c[coinnum], coinnum) + 1);
	}
	return memo[amount][coinnum];
}