#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  set<pair<long long int, long long int>> s;
  vector<long long int> v(n, 1);
  for (long long int i = 0; i < n; i++) {
    if ((long long int)s.size() == 0) {
      s.insert({a[i], i});
      continue;
    }
    long long int val = a[i] - k;
    while ((long long int)s.size() >= 1) {
      auto it = s.lower_bound({val, -1});
      if (it == s.end() || (*it).first > a[i] + k) break;
      v[i] = max(v[i], v[(*it).second] + 1);
      s.erase(it);
    }
    s.insert({a[i], i});
  }
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    ans = max(ans, v[i]);
  }
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
