#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<int> dis(n), pre(n);
  for (int i = 0; i < n; i++) {
    dis[i] = 1;
    pre[i] = -1;
    for (int j = i - 1; j >= 0; j--) {
      if (abs(a[i] - a[j]) <= k && dis[j] + 1 > dis[i]) {
        pre[i] = j;
        dis[i] = dis[j] + 1;
      }
    }
  }
  cout << dis[n - 1] << endl;
  return 0;
}
