#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int K;
int func(const vector<int>& vec, int n, int m, int l) {
  if (n < vec.size()) {
    int ret1 = func(vec, n + 1, m, l);
    int ret2 = 0;
    if (m == -1 || abs(vec[m] - vec[n]) <= K) {
      ret2 = func(vec, n + 1, n, l + 1);
    }
    return max(ret1, ret2);
  } else {
    return l;
  }
}
int main() {
  int N;
  cin >> N >> K;
  vector<int> A(N);
  for (auto& a : A) {
    cin >> a;
  }
  cout << func(A, 0, -1, 0) << endl;
  return 0;
}
