#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int INF = 1LL << 60;
int main() {
  Int N, M;
  cin >> N >> M;
  vector<Int> dp(N + 3, 0);
  vector<Int> stair(N + 3, 0);
  vector<Int> a(M, 0);
  for (Int i = 0; i < M; i++) cin >> a[i];
  for (Int i = 0; i < M; i++) stair[a[i]]++;
  for (Int i = 0; i < N; i++) {
    if (stair[i + 1] && stair[i + 1]) {
      dp[N] = 0;
      break;
    }
    if (stair[i + 1] == 0) dp[i + 1] = max(dp[i + 1], dp[i] + 1);
    if (stair[i + 2] == 0) dp[i + 2] = max(dp[i + 2], dp[i] + 1);
  }
  cout << dp[N] << endl;
}
