#include <bits/stdc++.h>
using namespace std;
const int64_t FPN_GE_10E9 = 10e9 + 7;
const int64_t FPN_LE_10E9 = 998244353;
int64_t mod64p(int64_t a, int64_t b) {
  return a - b * (a >= 0 ? a / b : a / b - 1);
}
int main() {
  const string MSG_YN[] = {"No", "Yes"};
  const string MSG_ON[] = {"NG", "OK"};
  int N, K, ret = 0;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < (int)(N); i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  double m;
  if (N % 2 == 0)
    m = A.at(N / 2);
  else
    m = (double)(A.at(N / 2) + A.at(N / 2 + 1)) / 2;
  for (int i = 0; i < (int)(N); i++) {
    if (A.at(i) >= m - 3 and A.at(i) <= m + 3) {
      ret++;
    }
  }
  cout << ret << endl;
  return 0;
}
