#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> count(n - 1, 1);
  for (int i = 0; i < n - 1; i++) {
    int s = a[i];
    for (int ii = i + 1; ii < n; ii++) {
      if (max(s - a[ii], a[ii] - s) > k) {
        continue;
      }
      count[i] += 1;
      s = a[ii];
    }
  }
  sort(count.begin(), count.end());
  cout << count[n - 2];
}
