#include <bits/stdc++.h>
int main(int argc, const char* argv[]) {
  int n, k, m = 0, j = 1, a[300000], cnt = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  if (m < j) {
    if (abs(a[m] - a[j]) < 3) {
      cnt++;
      m = j;
    }
    j++;
  }
  printf("%d", cnt);
  return 0;
}
