#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a.at(i);
  vector<int> start;
  start.push_back(0);
  for (int i = 0; i < n - 1; i++) {
    if (abs(a.at(i) - a.at(i + 1)) > k) {
      start.push_back(i + 1);
    }
  }
  int ans = 0;
  for (int i = 0; i < (int)(start.size()); i++) {
    int now = a.at(i);
    int cnt = 0;
    for (int j = start.at(i) + 1; j < n; j++) {
      if (abs(now - a.at(j)) <= k) {
        cnt++;
        now = a.at(j);
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans + 1 << endl;
}
