#include <bits/stdc++.h>
using namespace std;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const vl dx = {1, 0, -1, 0, 1, 0, -1, 0};
const vl dy = {0, 1, 0, -1, 0, 1, 0, -1};
template <typename T>
T input() {
  T x;
  cin >> x;
  return x;
}
void Yes(bool ans) { cout << (ans ? "Yes" : "No") << endl; }
void YES(bool ans) { cout << (ans ? "YES" : "NO") << endl; }
ll ceil(ll a, ll b) { return (a + b - 1) / b; }
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll modpow(ll x, ll n, ll mod) {
  ll res = 1;
  for (ll i = 0; i < n; i++) {
    res = res * x % mod;
  }
  return res;
}
ll MODpow(ll x, ll n) {
  ll res = 1;
  for (ll i = 0; i < n; i++) {
    res = res * x % MOD;
  }
  return res;
}
int main() {
  ll n, k;
  cin >> n >> k;
  vl a(n);
  for (ll i = 0; i < (ll)n; i++) cin >> a[i];
  queue<ll> q;
  q.push(0);
  ll ans = 1;
  while (!q.empty()) {
    ll index = q.front();
    q.pop();
    ll cnt = 1;
    bool flag = false;
    for (ll i = (ll)index + 1; i < (ll)n; i++) {
      if (abs(a[i] - a[index]) <= k) {
        flag = true;
        cnt++;
        index = i;
      } else if (!flag) {
        q.push(i);
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}
