#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long fceil(long long a, long long b) {
  return (a % b == 0 ? a / b : a / b + 1);
}
int main() {
  int n, m, a;
  cin >> n >> m;
  vector<int> ctr_trans(n + 1, 0);
  vector<bool> is_hole(n + 1, false);
  for (int i = 0; i < m; i++) {
    cin >> a;
    is_hole[a] = true;
  }
  ctr_trans[0] = 1;
  ctr_trans[1] = (int)(!is_hole[1]);
  for (int i = 2; i <= n; i++) {
    if (is_hole[i])
      continue;
    else
      for (int j = i - 1; j >= max(0, i - 2); j--) ctr_trans[i] = ctr_trans[j];
  }
  cout << ctr_trans[n] << endl;
  return 0;
}
