#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long power(long long a, long long n, long long p = mod) {
  if (n < 0) return 0;
  long long ans = 1;
  while (n) {
    if (n & 1) ans = (ans * a) % p;
    a = (a * a) % p;
    n >>= 1;
  }
  return ans;
}
long long inverse(long long x, long long p = mod) { return power(x, p - 2); }
void pre(void) {}
void solve(void) {
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n);
  for (long long i = 0; i < n; i++) cin >> arr[i];
  vector<long long> dp(n, 1);
  vector<long long> ne(n, -1);
  stack<long long> s;
  s.push(0);
  for (long long i = 1; i < n; i++) {
    while (s.size() && abs(arr[s.top()] - arr[i]) <= k) {
      ne[s.top()] = i;
      s.pop();
    }
    s.push(i);
  }
  for (long long i = 0; i < n; i++) {
    if (ne[i] != -1) {
      dp[ne[i]] = max(dp[ne[i]], dp[i] + 1);
    }
  }
  long long max_ = 0;
  for (long long i = 0; i < n; i++) {
    max_ = max(max_, dp[i]);
  }
  cout << max_ << '\n';
}
int32_t main(void) {
  std::ios::sync_with_stdio(0);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  pre();
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
