#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  queue<pair<long long, long long> > Q;
  Q.emplace(-1, 0);
  for (int i = 0; i < n; i++) {
    int m = Q.size();
    long long a = A[i];
    for (int j = 0; j < m; j++) {
      auto p = Q.front();
      Q.pop();
      if (p.first == -1 or abs(p.first - a) <= k) {
        Q.emplace(a, p.second + 1);
      } else {
        Q.push(p);
      }
    }
  }
  long long ma = 0;
  while (Q.size()) {
    auto p = Q.front();
    Q.pop();
    ma = max(ma, p.second);
  }
  cout << ma << endl;
  return 0;
}
