#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];
  vector<int> b(n);
  b.back() = 1;
  for (int i = n - 2; i >= 0; i--) {
    int cnt = 1;
    for (int j = i + 1; j < n; j++) {
      if (abs(a[i] - a[j]) <= k) cnt = max(b[j] + 1, cnt);
    }
    b[i] = cnt;
  }
  cout << b[0] << endl;
}
