#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;
int M, N;
int a[101];
LL d[101][10001];
LL f(int pos, int M)
{
if (d[pos][M] != 0)
return d[pos][M];
if (M == 0)
return 1;
if (pos >= N)
return 0;
if (M < 0)
return 0;
d[pos][M] = f(pos + 1, M) + f(pos + 1, M - a[pos]);
return d[pos][M];
}
int main()
{
cin >> M >> N;
for (int i = 0; i < N; i++)
{
cin >> a[i];
}
cout << f(0, M);
return 0;
}