#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n, -1);
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (abs(a[i] - a[j]) <= k) {
        b[i] = j;
        break;
      }
    }
  }
  int s;
  int max_s = 0;
  vector<int> c(n, 1);
  int curr_i = 0;
  int next = 0;
  while (accumulate(c.begin(), c.end(), 0)) {
    s = 0;
    while (next >= 0) {
      c[next] = 0;
      next = b[next];
      s++;
    }
    if (s > max_s) {
      max_s = s;
    }
    for (int i = curr_i; i < n; i++) {
      if (c[i]) {
        curr_i = i;
        break;
      }
    }
    next = curr_i;
  }
  cout << max_s << endl;
}
