#include <bits/stdc++.h>
using namespace std;
int check[300000];
int dp(int M, int s, int e, int k, int noe[]) {
  int newM = M;
  check[s] = 1;
  for (int i = s + 1; i < e; i++) {
    if (check[i] != 1 && abs(noe[i] - noe[s]) <= k) {
      newM = max(newM, dp(M + 1, i, e, k, noe));
    }
  }
  return newM;
}
int main() {
  int noe[300000];
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> noe[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp(1, i, n, k, noe));
  cout << ans;
}
