#include <stdio.h>
#define INF 21

int min(int x,int y){
	return (x<y)?x:y;
}
int main(void){
	int n,m,c[20],t[50002],i,j;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;++i){
		scanf("%d",&c[i]);
	}
	
	for(i=0;i<=n;++i){
		t[i]=INF;
	}
	t[0]=0;
	
	for(i=0;i<=m;++i){
		for(j=c[i];j<=n;++j){
			t[j] = min(t[j],t[j-c[i]]+1);
		}
	}
	printf("%d\n",t[n]);
	return 0;
}