#include <bits/stdc++.h>
using namespace std;
void INX() {}
template <typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail) {
  cin >> head;
  INX(forward<Tail>(tail)...);
}
void OUTX() {}
template <typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail) {
  cout << head << endl;
  OUTX(forward<Tail>(tail)...);
}
int main() {
  long long N, K;
  INX(N, K);
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) {
    INX(A[i]);
  }
  vector<long long> f(N);
  f[0] = 1;
  for (long long i = 1; i < N; i++) {
    long long tmpmax = -1;
    for (long long j = 0; j < i; j++) {
      if (abs(A[i] - A[j]) <= K && tmpmax < f[j]) {
        tmpmax = f[j];
      }
    }
    f[i] = (tmpmax < 0 ? 1 : tmpmax + 1);
  }
  OUTX(f[N - 1]);
  return 0;
}
