#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> seq(n), lis(n, 1);
  for (int i = 0; i < n; i++) cin >> seq[i];
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (abs(seq[i] - seq[j]) <= k && lis[j] + 1 > lis[i]) lis[i] = lis[j] + 1;
    }
  }
  cout << lis[n - 1];
}
