#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <ctime>
#include <algorithm>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int) n; i++)
#define seta(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define all(a) (a).begin(), (a).end()

const string name = "army";

const int NMAX = 17;
int n, m, a[NMAX], p[NMAX], now[NMAX], ans;

void calc()
{
	int ok = 0, num, tmp;
	forn(i, 1 << n)
	{
		num = 0;
		forn(j, n)
			if (i & (1 << j))
				now[num++] = p[j];

		if (m == num)
		{	tmp = 1;
			forn(j, num)
				if (now[j] != a[j])
				{
					tmp = 0;
					break;
				}
			if (tmp) ok = 1;
		}

		tmp = 1;
		forn(j, num - 1)
			if (now[j] > now[j + 1])
			{
				tmp = 0;
				break;
			}
				
		if (tmp && num > m) return;
	}
	if (ok) ans++;
}

int main()
{
	freopen((name + ".in").data(), "r", stdin);
	freopen((name + ".out").data(), "w", stdout);

	cin >> n >> m;
	forn(i, n)
		p[i] = i;
	forn(i, m)
	{
		cin >> a[i];
		a[i]--;
	}
	ans = 0;
	while (true)
	{
		calc();
		if (!next_permutation(p, p + n)) break;
	}
	cout << ans << endl;
	cerr << clock() << endl;

	return 0;
}
