#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < (n); i++) cin >> a[i];
  for (int i = 0; i < (m - 2); i++) {
    if (a[i + 1] == a[i] + 1 && a[i + 2] == a[i + 1] + 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  vector<int> dp(m);
  dp[m - 1] = 1;
  dp[m - 2] = 1;
  dp[m - 3] = 1;
  for (int i = m - 4; i >= 0; i--) {
    if (a[i] == i) dp[i] = 0;
    dp[i] = dp[i + 1] + dp[i + 2];
  }
  int ans = 0;
  for (int i = 0; i < (m); i++) {
    ans += dp[i];
  }
  cout << ans << endl;
}
