#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, INF = -1e9;
  ;
  cin >> N >> K;
  vector<int> inp(N), dp(N, 1);
  for (int i = 0; i < N; ++i) {
    cin >> inp[i];
  }
  for (int i = 1; i < N; ++i) {
    int maxi = INF;
    for (int j = i - 1; j >= 0; --j) {
      if (abs(inp[i] - inp[j]) <= K) maxi = max(maxi, 1 + dp[j]);
    }
    if (maxi != INF) dp[i] = maxi;
  }
  int maxi = INF;
  for (int i = 0; i < N; ++i) {
    maxi = max(maxi, dp[i]);
  }
  cout << maxi;
  return 0;
}
