#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
long long int i, j, n, m, k, ans;
long long int a[300000];
long long int maxfromhere[300000];
int main() {
  scanf(" %lld %lld", &n, &k);
  for (i = 0; i < n; i++) {
    scanf(" %lld", &a[i]);
    maxfromhere[i] = 1;
  }
  long long int maxtmp = 1;
  maxfromhere[n - 1] = 1;
  for (i = n - 2; i >= 0; i--) {
    for (j = i + 1; j < n; j++) {
      if (abs(a[j] - a[i]) <= k) {
        maxfromhere[i] = max(maxfromhere[i], maxfromhere[j] + 1);
        if (maxtmp == maxfromhere[j]) {
          maxtmp++;
          break;
        }
      }
    }
  }
  printf("%lld\n", maxtmp);
}
