#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int now = a[0];
  int res = n;
  for (int i = 0; i < n; ++i) {
    if (abs(now - a[i]) > 3) {
      res--;
    } else {
      now = a[i];
    }
  }
  cout << res << endl;
  return 0;
}
