// WHY
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

vector<int> cards;
int minimum = INT_MAX;
int curr = 0;

void func(int s, int maxPos) {
	if (s == 0) {
		if (curr < minimum) minimum = curr;
		return;
	}
	for (int i = ceil(float(s) / cards[maxPos]); i >= 0; i--) {
		curr += i;
		if ((ceil(float(s - i * cards[maxPos])) / cards[maxPos + 1]) + curr > minimum) {
			curr -= i;
			break;
		}
		func(s - i * cards[maxPos], maxPos + 1);
		curr -= i;
	}
}

int main() {
	int s, n;
	cin >> s >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		cards.push_back(a);
	}
	sort(cards.begin(), cards.end(), greater<int>());
	func(s, 0);
	cout << minimum << endl;

	return 0;
}