#include <bits/stdc++.h>
using namespace std;
int maxi = 0;
void findmax(vector<int> &a, int i, int count, int prev, int k) {
  if (i >= a.size()) {
    if (maxi < count) {
      maxi = count;
    }
    return;
  }
  if (prev == -1 || abs(a[i] - prev) <= k) {
    findmax(a, i + 1, count + 1, a[i], k);
    findmax(a, i + 1, count, prev, k);
  } else {
    findmax(a, i + 1, count, prev, k);
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  findmax(a, 0, 0, -1, k);
  printf("%d\n", maxi);
  return 0;
}
