#include<stdio.h>

int min(int x, int y){
	if(x <= y) return x;
	else return y;
}
int main(){
int i,j,n,m;
scanf("%d",&n);
scanf("%d",&m);
int C[m];
for(i=0;i<m;i++)
scanf("%d",&C[i]);
int T[n+1];
for(i=0;i<=n;i++)
T[i] = 10001;
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;
}