#include <fstream>
#include <cstring>
#include <iostream>
#include <cassert>

using namespace std;

const int maxN = 16;
const int maxP = 81 * 81 * 81 * 81;
const int maxH = 5000017;
const int maxQ = 500000;

int n, k;
int a[maxN], aa[maxN];
int p3[maxN + 1];
long long f[maxH];
int h[maxH];
int q[maxQ], fi, la;

inline int get( int p, int i ) {
  return (p / p3[i]) % 3;
}

inline int hGet( int pp ) {
  int hp = pp % maxH;
  while (h[hp] != pp && h[hp] != -1) {
    if (++hp == maxH) {
      hp = 0;
    }
  }
  if (h[hp] == -1) {
    h[hp] = pp;
  }
  return hp;
}

int main() {
  ifstream fin("army.in");
  ofstream fout("army.out");

  fin >> n >> k;
  memset(aa, -1, sizeof(aa));
  for (int i = 0; i < k; ++i) {
    fin >> a[i];
    a[i]--;
    aa[a[i]] = i;
  }
  p3[0] = 1;
  for (int i = 1; i <= n; ++i) {
    p3[i] = p3[i - 1] * 3;
  }
  long long ans = 0;
  memset(h, -1, sizeof(h));
  memset(f, -1, sizeof(f));
  f[0] = 1;
  fi = la = 0;
  q[la++] = 0;
  while (fi < la) {
    int p = q[fi++];
    int hp = hGet(p);
//  for (int p = 0; p < p3[n]; ++p) {
    int v[maxN], is[maxN], vk = 0;
    bool ta = true;
    for (int i = 0; i < n; ++i) {
      int t = get(p, i);
      if (t == 1) {
        v[vk++] = i;
        is[i] = 1;
      } else if (t == 2) {
        is[i] = 1;
      } else {
        is[i] = 0;
        ta = false;
      }
    }
    if (ta) {
      ans += f[hp];
    }
    for (int i = n - 1; i >= 0; --i) {
      int pos = vk;
      if (!is[i]) {
        if (aa[i] > 0 && !is[a[aa[i] - 1]]) {
          continue;
        }
        while (pos > 0 && v[pos - 1] > i) {
          pos--;
        }
        if (pos >= k || (aa[i] != -1 && aa[i] != pos)) {
          continue;
        }
        int pp = p;
        if (pos < vk && i < v[pos]) {
          pp += p3[v[pos]];
        }
        if (pos == vk || i < v[pos]) {
          pp += p3[i];
        } else {
          pp += 2 * p3[i];
        }
        int hpp = hGet(pp);
        if (f[hpp] == -1) {
          f[hpp] = 0;
          q[la++] = pp;
          assert(la < maxQ);
        }
        f[hpp] += f[hp];
      }
    }
  }
  cerr << "la=" << la << endl;
  fout << ans << endl;

  return 0;
}
