#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 = 6000017;
const int maxQ = 500000;
const int maxTl = 8;
const int maxT = (1 << (2 * maxTl));

int n, k;
int a[maxN], aa[maxN];
long long f[maxH];
unsigned h[maxH];
unsigned q[maxQ];
int fi, la;
int cnt[maxT];
int fo[maxT];
int fz[maxT];

inline int get( int p, int i ) {
  return (p >> (2 * i)) & 3;
}

inline int hGet( unsigned pp ) {
  int hp = pp % maxH;
  while (h[hp] != pp && f[hp] != -1) {
    if (++hp == maxH) {
      hp = 0;
    }
  }
  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;
  }
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < maxT; ++i) {
    cnt[i] = ((i >> 2) ? cnt[i >> 2] : 0) + !!(i & 3);
    fo[i] = maxTl;
    for (int j = 0; j < maxTl; ++j) {
      if (((i >> (2 * j)) & 3) == 1) {
        fo[i] = j;
        break;
      }
    }
    fz[i] = maxTl;
    for (int j = 0; j < maxTl; ++j) {
      if (((i >> (2 * j)) & 3) == 0) {
        fz[i] = j;
        break;
      }
    }
  }
  long long ans = 0;
  memset(h, -1, sizeof(h));
  memset(f, -1, sizeof(f));
  f[0] = 1;
  h[0] = 0;
  fi = la = 0;
  q[la++] = 0;
  int v[maxN], vk;
  while (fi < la) {
    unsigned p = q[fi++];
    int hp = hGet(p);
    vk = 0;
    unsigned tp = p;
    int add = 0;
    while (tp) {
      int ne = fo[tp & (maxT - 1)];
      if (ne < maxTl) {
        v[vk++] = ne + add;
        ne++;
      }
      tp >>= 2 * ne;
      add += ne;
    }
    if (cnt[p & (maxT - 1)] + cnt[p >> (2 * maxTl)] == n) {
      ans += f[hp];
    } else {
      int pos = 0;
      tp = p;
      add = 0;
      while (add < n) {
        int ne = fz[tp & (maxT - 1)];
        if (ne < maxTl) {
          int i = ne + add;
//          cerr << "i=" << i << endl;
          if (i < n) {
            while (pos < vk && v[pos] < i) {
              pos++;
            }
            if (!(aa[i] > 0 && !get(p, a[aa[i] - 1])) && !(pos >= k || (aa[i] != -1 && aa[i] != pos))) {
              unsigned pp = p;
              if (pos < vk && i < v[pos]) {
                pp += (1 << (2 * v[pos]));
              }
              if (pos == vk || i < v[pos]) {
                pp += (1 << (2 * i));
              } else {
                pp += (2 << (2 * i));
              }
              int hpp = hGet(pp);
              if (f[hpp] == -1) {
                h[hpp] = pp;
                f[hpp] = 0;
                q[la++] = pp;
              }
              f[hpp] += f[hp];
            }
          }
          ne++;
        }
        tp >>= 2 * ne;
        add += ne;
      }
    }
  }
  cerr << "la=" << la << endl;
  fout << ans << endl;

  return 0;
}
