#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];

  rep(i, n) {
    if (used[i]) continue;
    ll t = a[i], tans = 1;
    for (int j = i + 1; j < n; ++j) {
      if (abs(t - a[j]) <= k) t = a[j], tans++, used[j] = true;
    }
    ans = max(ans, tans);
  }

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