#include <bits/stdc++.h>
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy8[8] = {0, 1, 0, -1, 1, -1, 1, -1};
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;
}
using namespace std;
std::vector<unsigned long long> genprimevec(const unsigned long long N);
long long extgcd(long long a, long long b, long long& x, long long& y);
long long nCr(long long n__, long long r__);
void stat();
template <typename T>
T fact(T num__);
unsigned long long modpow(int x__, int n__, long long mod__);
template <typename T>
void debug(const T& t__);
constexpr long long mod10_9p7 = 1000000000 + 7;
int n, k;
int ans = 0;
std::vector<int> v;
void f(int x, int sum) {
  chmax(ans, sum);
  if (x == n) {
    return;
  }
  for (int i = x + 1; i != n; ++i) {
    if (abs(v[i] - v[x]) <= k) {
      ++sum;
      f(i, sum);
      break;
    }
  }
}
int main() {
  stat();
  cin >> n >> k;
  v.resize(n);
  for (unsigned long long i = 0; i < (unsigned long long)(n); ++i) {
    cin >> v[i];
  }
  for (unsigned long long i = 0; i < (unsigned long long)(n); ++i) {
    f(i, 0);
  }
  cout << ans + 1 << endl;
  return 0;
}
long long extgcd(long long a, long long b, long long& x, long long& y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long d = extgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
std::vector<unsigned long long> genprimevec(const unsigned long long N) {
  std::vector<bool> is_prime(N + 1);
  for (unsigned long long i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  std::vector<unsigned long long> P;
  for (unsigned long long i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (unsigned long long j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}
void stat() {}
long long nCr(long long n__, long long r__) {
  long long num__ = 1;
  for (long long i__ = 1; i__ <= r__; i__++) {
    num__ = num__ * (n__ - i__ + 1) / i__;
  }
  return num__;
}
template <typename T>
T fact(T num__) {
  if (num__ == 1) {
    return 1;
  }
  return num__ * fact(num__ - 1);
}
unsigned long long modpow(int x__, int n__, long long mod__) {
  long long ret__ = 1;
  for (long long i__ = 0; i__ < n__; ++i__) {
    ret__ = ret__ * x__ % mod__;
  }
  return ret__;
}
template <typename T>
void debug(const T& t__) {}
