#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (auto &i : a) cin >> i;
  vector<long long> dp(n);
  for (int i = 0; i < n; i++) {
    dp[i] = 1;
    for (int j = i - 1; j >= 0; j--) {
      if (abs(a[i] - a[j]) <= k) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
  }
  long long m = 0;
  for (int i = 0; i < n; i++) m = max(m, dp[i]);
  cout << m;
  return 0;
}
