#include <bits/stdc++.h>
using namespace std;
long long f(long long i, vector<long long> &v, vector<long long> &dp,
            long long k) {
  long long n = v.size();
  if (dp[i] != -1) return dp[i];
  dp[i] = 0;
  for (long long j = i + 1; j < n; j++) {
    if (abs(v[j] - v[i]) <= k) {
      dp[i] = max(f(j, v, dp, k), dp[i]);
    }
  }
  dp[i]++;
  return dp[i];
}
int main() {
  long long t = 1;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    vector<long long> dp(n, -1), v(n);
    for (long long i = 0; i < n; i++) cin >> v[i];
    long long x = f(0, v, dp, k);
    cout << *max_element(dp.begin(), dp.end());
  }
}
