#include <bits/stdc++.h>
using namespace std;
const int nax = 3 * 1e5 + 4;
int a[nax];
int pre[nax];
int cnt[nax];
bool sorter2(const pair<long int, long int> &a,
             const pair<long int, long int> &b) {
  return (a.second < b.second);
}
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i - 1; j >= 0; j--) {
      if (abs(a[i] - a[j]) <= k) {
        pre[i] = j;
        cnt[j] = cnt[i] + 1;
      }
    }
  }
  int mmax = 0;
  for (int i = 0; i < n; i++) {
    mmax = max(mmax, cnt[i]);
  }
  cout << mmax + 1 << endl;
}
