# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <cstring>
# include <string>
# include <iostream>
# include <iomanip>
# include <algorithm>
# include <stack>
# include <vector>
# include <queue>
using namespace std;
static const int mmax = 20;
static const int nmax = 50000;
static const int inf = (1 << 29);
int main()
{
int n, m;
cin >> n >> m;
int c[21];
int t[nmax+1];
for (int i = 1; i <= m; i++)
{
cin >> c[i];
}
//memset(t,inf,sizeof(t));
for (int i = 0; i < nmax + 1; i++)t[i] = inf;
t[0] = 0;//边缘条件
for (int i = 1; i <= m; i++)
{
for (int j = 0; j + c[i] <= n; j++)
{
t[j + c[i]] = min(t[j+c[i]],t[j]+1);
}
}
cout << t[n] << endl;
return 0;
}