#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  vector<int> A;
  cin >> N >> K;
  A.resize(N, 0);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  vector<int> C(N, 0);
  C[N - 1] = 1;
  for (int n = N - 2; n >= 0; --n) {
    int max_length = 0;
    for (int nn = n + 1; nn < N; ++nn) {
      int length = (abs(A[n] - A[nn]) <= K) ? (C[nn] + 1) : (C[nn]);
      if (max_length < length) {
        max_length = length;
      }
    }
    C[n] = max_length;
  }
  cout << C[0] << endl;
  return 0;
}
