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

int main(void)
{
	int i,j,k;
	int count[50002]={}; //????????????????°??????°????????????
	int n,m,coin[20]; //input

	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&coin[i]);
		count[coin[i]]=1;
	}
	i=1;
	while(1){
		for(j=0;j<n;j++){	//????¨????????????§????????????
			if(count[j]==i){
				for(k=0;k<m;k++){//?????????????????°???????????????
					if(count[j+coin[k]]==0){
						count[j+coin[k]]=i+1;
					}
					if(count[n]!=0)break;
				}
			}
			if(count[n]!=0) break;
		}
		if(count[n]!=0) break;
		i++;
	}
	printf("%d\n",count[n]);
	
	return 0;
}