#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 8;
const long long MOD = 1e9 + 7;
const long long LLINF = 1e18;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (long long i = long long(0); i < long long(n); i++) cin >> a[i];
  vector<bool> used(n, false);
  int ans = 0;
  for (long long i = long long(0); i < long long(n); i++) {
    if (used[i]) continue;
    int tmp = 1;
    int prev = i;
    for (int j = i + 1; j < n; ++j) {
      if (abs(a[prev] - a[j]) <= k) {
        prev = j;
        used[j] = true;
        ++tmp;
      }
    }
    prev = i;
    for (int j = i - 1; j >= 0; --j) {
      if (abs(a[prev] - a[j]) <= k) {
        prev = j;
        ++tmp;
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
