#include<bits/stdc++.h>
using namespace std;
const int INF=0x7fffffff;
int m,n,k;
int f[511000];
int a[11];
int main()
{ freopen("change.in","r",stdin);
freopen("change.out","w",stdout);
scanf("%d%d",&m,&n);
memset(f,233333,sizeof(f));
f[0]=0;
for (int i=1;i<=n;i++)
{scanf("%d",&a[i]);
for (int j=a[i];j<=m;j++)
f[j]=min(f[j-a[i]]+1,f[j]);}
printf("%d",f[m]);
return 0;
}