#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k, a[3000000], dmax;
  cin >> n >> k;
  int i, j, dp[3000000];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0] = 1;
  for (i = 1; i < n; i++) {
    dmax = 0;
    for (j = 0; j < i; j++) {
      if (abs(a[i] - a[j]) <= k && dp[j] > dmax) {
        dmax = dp[j];
      }
    }
    dp[i] = dmax + 1;
  }
  dmax = 0;
  for (i = 0; i < n; i++) {
    dmax = max(dp[i], dmax);
  }
  cout << dmax << endl;
}
