#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  vector<long long> DP(N + 10000, 1);
  for (int X = 0; X < N; X++) {
    cin >> V[X];
  }
  for (int X = 0; X < N; X++) {
    for (int Y = 1; X + Y < N; Y++) {
      if (abs(V[X] - V[X + Y]) <= K) {
        if (DP[X] + 1 > DP[X + Y]) {
          DP[X + Y] = DP[X] + 1;
        }
      }
    }
  }
  cout << DP[N - 1] << endl;
}
