#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, count = 0, ans = 0, k, a;
  vector<int> v;
  cin >> t >> k;
  while (t > 0) {
    cin >> a;
    v.push_back(a);
    t--;
  }
  int i, j, prev, p;
  bool found = false;
  for (i = 0; i < v.size(); i++) {
    prev = v[i];
    for (j = i + 1; j < v.size(); j++) {
      if (abs(v[j] - v[i]) <= k) {
        found = true;
        break;
      };
    }
    if (found == true) break;
  }
  for (i = 0; i < j; i++) {
    prev = v[i];
    count = 0;
    for (p = i + 1; p < v.size(); p++) {
      if (abs(v[p] - prev) <= k) {
        count++;
        prev = v[p];
      }
    }
    if (count > 0)
      ans = max(ans, count + 1);
    else
      ans = max(ans, count);
  }
  cout << ans;
  return 0;
}
