#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int main(void) {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long> dp(n, 1);
  for (long long i = 0; i < n; ++i) {
    for (long long j = i + 1; j < n; ++j) {
      if (abs(a[i] - a[j]) > k) {
        continue;
      }
      dp[j] = max(dp[j], dp[i] + 1);
    }
  }
  cout << dp[n - 1];
}
