#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A;
  for (long long i = 0; i < M; i++) {
    long long a;
    cin >> a;
    A.push_back(a);
  }
  for (long long i = 0; i < M - 1; i++) {
    if ((A[i] + 1) == A[i + 1]) {
      cout << 0;
      return 0;
    }
  }
  return 0;
}
