#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using tlll = tuple<ll, ll, ll>;
int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N), G(N, 1), MV(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll maxl = 0;
  MV[N - 1] = 1;
  for (ll i = N - 1; i >= 0; i--) {
    for (ll j = i + 1; j < N; j++) {
      if (abs(A[j] - A[i]) <= K) {
        G[i] = max(G[i], G[j] + 1);
        if (maxl < G[j] + 1) {
          maxl = G[j] + 1;
          MV[i] = maxl;
          break;
        }
        if (MV[j] <= G[i]) {
          MV[i] = maxl;
          break;
        }
      }
    }
  }
  sort(G.begin(), G.end());
  cout << G[G.size() - 1] << endl;
}
