#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int mod = 998244353;
const int maxn = 1e6 + 3;
long long prime[100002];
long long exp(long long a, long long b);
void sieve(long long n);
long long gcd(long long a, long long b);
long long countdigit(long long n);
vector<long long> ft;
long long mul(long long a, long long b) {
  long long ans = ((a % mod) * (b % mod)) % mod;
  return ans % mod;
}
long long sub(long long a, long long b) {
  long long ans = (a - b + mod) % mod;
  return ans;
}
long long add(long long a, long long b) {
  long long ans = (a + b) % mod;
  return ans;
}
long long fun(long long number) { return (long long)log2(number) + 1; }
long long dp[300005];
long long n, k;
long long a[300005];
long long sun(long long index) {
  if (index == n) {
    dp[index] = 1;
    return 1;
  }
  if (dp[index] != 0) {
    return dp[index];
  } else {
    long long temp = index;
    long long c = 0;
    for (int i = index + 1; i < n + 1; i++) {
      if (abs(a[temp] - a[i]) <= k) {
        c++;
        if (dp[i] != 0) {
          dp[temp] = dp[i] + 1;
        } else {
          dp[temp] = sun(i) + 1;
        }
        temp = i;
      }
    }
    if (c == 0) {
      dp[index] = 1;
      return 1;
    }
  }
}
void solve() {
  cin >> n >> k;
  for (int i = 1; i < n + 1; i++) cin >> a[i];
  for (long long i = n; i >= 1; i--) {
    if (dp[i] == 0) {
      sun(i);
    }
  }
  long long ans = 0;
  for (int i = 1; i < n + 1; i++) ans = max(ans, dp[i]);
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
long long exp(long long a, long long b) {
  int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
void sieve(long long n) {
  for (long long i = 0; i <= n; i++) {
    prime[i] = 1;
  }
  prime[0] = 0;
  prime[1] = 0;
  for (long long i = 2; i <= n; i++) {
    if (prime[i] == 1) {
      for (long long j = 2; i * j <= n; j++) {
        prime[i * j] = 0;
      }
    }
  }
}
long long countdigit(long long n) { return floor(log10(n) + 1); }
