#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);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  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] = G[j] + 1;
        break;
      }
    }
  }
  sort(G.begin(), G.end());
  cout << G[G.size() - 1] << endl;
}
