#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, A, cnt = 0, flag = 0;
  cin >> N >> A;
  int M[A];
  for (int i = 0; i < A; i++) {
    cin >> M[i];
  }
  for (int i = 0; i < A - 1; i++) {
    if (M[i] != M[i + 1] - 1) {
      if (M[i] != M[i + 1] - 2) {
        cnt = cnt + 2;
      } else {
        cnt = cnt + 3;
      }
    } else {
      flag = 1;
      break;
    }
  }
  int u = 1;
  if (flag == 1) {
    cout << 0 << endl;
  } else {
    for (int i = 0; i < N - cnt - 4; i++) {
      u = 2 * u;
    }
    cout << u << endl;
  }
  return 0;
}
