#include <bits/stdc++.h>
using namespace std;
int n, a[300001], l[300001], k;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  int maxlen = 1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    l[i] = 1;
    for (int j = 0; j < i; ++j) {
      if (abs(a[j] - a[i]) <= k) {
        l[i] = max(l[i], l[j] + 1);
      }
    }
    maxlen = max(maxlen, l[i]);
  }
  cout << maxlen;
  return 0;
}
