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