#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
const int mod = 1e9 + 7;
int A[maxn];
int B[maxn];
struct node {
  int id;
  bool friend operator<(const node& a, const node& b) {
    return B[a.id] < B[b.id];
  }
};
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }
  B[1] = 1;
  for (int i = 2; i <= n; i++) {
    B[i] = 1;
    for (int j = 1; j < i; j++) {
      if (A[i] - A[j] <= k && A[j] - A[i] <= k) B[i] = max(B[i], B[j] + 1);
    }
  }
  printf("%d\n", B[n]);
  return 0;
}
