// coin mondai

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

int c[20]; // ?????¢

int countit(int n,int m){
	int unchi, i;
	int min_unchi=999999;
	if(n % c[m-1] == 0){return n/c[m-1];}
	for(i=0;i<m;i++){
		if(n-c[i]>0){
			unchi = countit(n-c[i],i+1)+1;
		}else if(n-c[i]==0){
			unchi = 1;
		}else{
			unchi=99999;
		}
		if(min_unchi>unchi){min_unchi=unchi;}
	}
	return min_unchi;
}

int main(void){
	int n, m, i;
	scanf("%d %d", &n, &m);
	for(i=0;i<m;i++){
		scanf("%d", &c[i]);
	}
	// sort
	int tmp;
	int kaeritai,monosugokukaeritai;
	for(kaeritai=0;kaeritai<m;kaeritai++){
		for(monosugokukaeritai=kaeritai;monosugokukaeritai<m;monosugokukaeritai++){
			if(c[kaeritai]>c[monosugokukaeritai]){
				tmp = c[kaeritai];
				c[kaeritai] = c[monosugokukaeritai];
				c[monosugokukaeritai] = tmp;
			}
		}
	}
	// ??????
	int unchi;
	unchi = countit(n,m);
	printf("%d\n", unchi);
	return 0;
}