#include <bits/stdc++.h>

#include <atcoder/all>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using namespace atcoder;
typedef long long ll;

bool used[300005];

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<ll>> res;

  rep(i, n) {
    // cout << "0: " << a[i] << endl;
    bool ok = false;
      for (int j = 0; j < res.size(); ++j) {
        if (abs(res[j].back() - a[i]) <= k) {
          res[j].push_back(a[i]);
          ok = true;
          // cout << "1: " << a[i] << endl;
        }
      }
    if (!ok) {
      vector<ll> nw(1, a[i]);
      res.push_back(nw);
      // cout << "2: " << nw[0] << endl;
    }
    // cout << "3: " << a[i] << endl;
  }

  // cout << res.size() << endl;

  for (auto x : res) ans = max(ans, (ll)x.size());

  cout << ans << endl;
  return 0;
}