#include <iostream>
using namespace std;
const int maxN = 2003;
int v[maxN]; int n;
int mint(int lefts) {
	if(lefts==0) return 0;
	int mn = n;
	for(int i=0;i<n;i++){
		if(lefts==v[i]) return 1;
		if(lefts>=v[i]) mn=min(mn,mint(lefts-v[i])+1);
	}
	return mn;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	long long s; cin >> s >> n;
	for (int i=0;i<n;i++)cin>>v[i];
	cout<<mint(s)<<'\n';
		return 0;
	}