#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) cin >> A.at(i);
  vector<long long> DP(N);
  DP.at(0) = 1;
  for (long long i = 1; i < N; i++) {
    long long num = 1;
    for (long long j = i - 1; j >= 0; j--) {
      if (abs(A.at(i) - A.at(j)) <= K) num = max(num, DP.at(j) + 1);
    }
    DP.at(i) = num;
  }
  cout << DP.at(N - 1) << endl;
}
