#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
using pi = pair<int, int>;
const ll MOD = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
signed main() {
  ll n, k;
  cin >> n >> k;
  vl a(n);
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  vector<bool> seen(n, false);
  ll ans = 0;
  for (long long i = 0; i < (long long)(n - 1); i++) {
    if (seen[i]) continue;
    ll cnt = 1;
    ll now = a[i];
    for (long long j = i + 1; j < (long long)(n); j++) {
      if (abs(now - a[j]) <= k) {
        seen[j] = 1;
        cnt++;
        now = a[j];
      }
    }
    chmax(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
