#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

int mini = 9999, count, target, loop;
int h[11];

void go(int a, int count, int check[10]) {
	int j;
	if (a == target && count < mini) {
		mini = count;
	}
	else {
		for (j = 0; j < loop; j++) {
			if (check[j] == 1) {
				check[j] = 0;
				go(a + h[j], count + 1, check);
				check[j] = 1;
			}
		}
	}
	return;
}

int main() {
	ifstream filein("DATA4.txt");
	ofstream fileout("OUT4.txt");

	int i;
	int temp[10];

	for (i = 0; i < 10; i++)
		temp[i] = 1;

	filein >> target >> loop;

	for (i = 0; i < loop; i++) {
		filein >> h[i];
	}

	for (i = 0; i < loop; i++) {
		temp[i] = 0;
		go(h[i], 1, temp);
		temp[i] = 1;
	}
	
	if (mini == 9999)
		fileout << 0 << endl;
	else
		fileout << mini << endl;
	

	filein.close();
	fileout.close();
	return(0);
}

