#include <bits/stdc++.h>
using namespace std;
int n, k, ma;
int a[300100], b[300100];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  b[n] = 1;
  for (int i = n; i >= 1; i--) {
    b[i] = 1;
    for (int j = i + 1; j <= n; j++) {
      if (abs(a[i] - a[j]) <= k) b[i] = max(b[i], b[j] + 1);
      if (b[i] >= ma + 1) break;
    }
    ma = max(ma, b[i]);
  }
  printf("%d", ma);
  return 0;
}
