#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vector<bool> seem(n, false);
  int ans = 0;
  for (int i = 0; i < (int)(n - 1); i++) {
    if (seem[i]) continue;
    seem[i] = true;
    int t = 1;
    int pre = a[i];
    for (int j = i + 1; j < n; j++) {
      if (abs(pre - a[j]) <= k) {
        seem[j] = true;
        pre = a[j];
        t++;
      }
    }
    ans = max(ans, t);
  }
  cout << ans;
}
