#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2, 62);
int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> A(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> A[i];
  }
  ll ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    ll x = A[i];
    ll oo = 0;
    for (int j = 0; j < (int)(n); j++) {
      if (abs(x - A[j]) <= 3) {
        oo++;
      }
    }
    ans = max(ans, oo);
  }
  cout << ans - 1 << endl;
}
