#include <bits/stdc++.h>
using namespace std;
const int64_t M = 1e9 + 7, N = 1e6 + 5;
int64_t a[N], ans[N], n, k;
void f(int64_t node) {
  for (int64_t i = node + 1; i < n; i++) {
    if (abs(a[i] - a[node]) > k) continue;
    if (ans[i]) {
      ans[node] = ans[i];
      break;
    }
    f(i);
    ans[node] = ans[i];
    break;
  }
  ans[node] += 1;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  cin >> n >> k;
  for (int64_t i = 0; i < n; i++) cin >> a[i];
  for (int64_t i = 0; i < n; i++) {
    if (!ans[i]) f(i);
  }
  int64_t mx = 0;
  for (int64_t i = 0; i < n; i++) mx = max(mx, ans[i]);
  cout << mx;
}
