#include <bits/stdc++.h>
using namespace std;
int n, k, a[300009], ans, TO;
int main() {
  cin >> n >> k;
  TO = n - 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= TO; i++) {
    int res = 1;
    int o = i;
    for (int j = o + 1; j < n; j++) {
      if (abs(a[j] - a[o]) <= k) {
        TO = min(TO, j);
        res++;
        o = j;
      }
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
