#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T& a, const T& b) {
  a = max(a, b);
}
template <class T>
void chmin(T& a, const T& b) {
  a = min(a, b);
}
int tmp;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n), w(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  w[0] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= 0; j -= 1) {
      if (abs(v[i] - v[j]) <= k) {
        w[i] = max(w[i], w[j] + 1);
      }
    }
  }
  cout << w[n - 1] << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
