#include <iostream>
using namespace std;
const int N = 22;
int n, m;
int res = N;
int a[N];
void dfs(int u, int cnt, int sum)
{
if (sum == m) res = min(res, cnt);
if (u < 0 || sum > m) return;
dfs(u - 1, cnt + 1, sum + a[u]);
dfs(u - 1, cnt, sum);
}
int main()
{
cin >> m >> n;
for (int i = 0; i < n; i ++ )
cin >> a[i];
dfs(n - 1, 0, 0);
if (res == N) cout << 0 << endl;
else cout << res << endl;
return 0;
}