#include <bits/stdc++.h>
using namespace std;
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << P.first << " " << P.second;
}
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  for (auto v : V) os << v << " ";
  return cout << "";
}
template <class T>
ostream& operator<<(ostream& os, set<T> S) {
  for (auto s : S) os << s << " ";
  return cout << "";
}
const long long mod = 998244353;
long long inv(long long i) {
  if (i == 1) return 1;
  return (mod - ((mod / i) * inv(mod % i)) % mod) % mod;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long pwr(long long a, long long b) {
  a %= mod;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long i = n - 2, j = n - 1;
  vector<long long> a(n), dp(n, 1);
  for (int i = 0; i < n; i++) cin >> a[i];
  while (i >= 0) {
    if (j <= i) {
      i--;
      j = n - 1;
    } else if (abs(a[i] - a[j]) <= k) {
      dp[i] = max(dp[i], dp[j] + 1);
      j--;
    } else {
      j--;
    }
  }
  cout << (*max_element((dp).begin(), (dp).end())) << "\n";
}
