#include<stdio.h>
#define N 50010
#define M 25
#define INF 666666 

int a[N],v[M];

int main(){
	int m,n,Min,i,j,t;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
		scanf("%d",&v[i]);
	v[0] = 0;
	for(i=1;i<N;i++)
		a[i] = INF;
	a[0]=0;
	for(i=1;i<=n;i++){
		Min = t = INF;
		for(j=1;j<=m;j++){
			if(i-v[j]>=0) t = a[i-v[j]]+1;
			if(t<Min) Min = t;
		}
		a[i] = Min;
	}
	printf("%d\n",a[n]);
	return 0;
}