#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long double pi = acos(-1.0);
const long long MAX = 1000010;
const long long INF = 1ll << 60;
const long long MOD = 1000000007;
template <typename T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
inline void print(P a) { cout << a.first << " " << a.second << endl; }
template <typename T>
T bpow(T a, ll n) {
  T r(1);
  while (n) {
    if (n & 1) r *= a;
    a *= a;
    n >>= 1;
  }
  return r;
}
struct faster_io {
  faster_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  }
} faster_io_;
signed main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  vector<long long> used(n, -1);
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  long long cnt = 0;
  long long t = 0;
  bool end = false;
  long long ans = -1;
  while (!end) {
    long long st = 0;
    for (long long i = 0; i < (long long)(n); i++)
      if (used[i] == -1) {
        st = i;
        break;
      }
    long long pre = a[st];
    long long c = 0;
    for (long long i = (st); i < (long long)(n); i++) {
      if (used[i] == -1 && abs(pre - a[i]) <= k) {
        used[i] == t;
        pre = a[i];
        cnt++;
        c++;
        if (cnt == n) end = true;
      }
    }
    chmax(ans, c);
    t++;
    if (end) break;
  }
  cout << ans << endl;
  return 0;
}
