#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <queue>
#include <memory.h>
#include <stack>
#define mp make_pair
#define pb push_back                     
#define setval(a,v) memset(a,v,sizeof(a))

#if ( _WIN32 || __WIN32__ )
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

using namespace std;

typedef long long ll;
typedef long double ld;

#ifdef LOCAL
  ld start = clock();
#endif

const int MAXST = 3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3 + 10;
const int MAXN = 20;

ll dp[MAXST];
int prev[MAXN];
int temp[MAXN];
int cn[MAXN];
int ncnt[MAXN];
int n,k;
int armyt;
int st3[MAXN];

inline void decode(int it){
    for (int i = 0; i < n; i++)
        temp[i] = it % 3, it /= 3;
}

inline bool check(){
    int cnt = 0;
    for (int i = 0; i < n; i++){
        if (temp[i] == 0)
            return false;
        cnt += temp[i] == 1;
    }
    return (cnt == k);
}

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

  dp[0] = 1;
  scanf("%d %d",&n,&k);

  armyt = -1;

  for (int i = 0; i < n; i++)
    prev[i] = -2;
  for (int i = 0; i < k; i++){
    int a;
    scanf("%d",&a);
    prev[a-1] = armyt;
    ncnt[a-1] = i;
    armyt = a-1;
  }

  int sts = 1;

  for (int i = 0; i < n; i++)
    st3[i] = sts, sts *= 3;

  ll ans = 0;

  int stcnt = 0;

  for (int it = 0; it < sts; it++){
      if (dp[it] == 0)
        continue;
      stcnt++;
      decode(it);
      
      int cnt = 0;

      cn[n-1] = -1;
      for (int i = n-2; i >= 0; i--)
         if (temp[i+1] == 1)
            cn[i] = i+1;
         else
            cn[i] = cn[i+1];

      for (int i = 0; i < n && cnt < k; i++)
        if (temp[i] == 0 && (prev[i] < 0 || temp[prev[i]] != 0)){
            if (prev[i] == -2 || ncnt[i] == cnt)
                dp[it + st3[i] + (cn[i] == -1 ? 0 : st3[cn[i]])] += dp[it];                         
        }
        else if (temp[i] == 1)
            cnt++;
            
      if (check()){
        ans += dp[it];
      }
  }


  cout << ans << endl;
  #ifdef LOCAL
    cerr << (clock()-start)/CLOCKS_PER_SEC << endl;
  #endif
  return 0;
}

