#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int len, maxlen = 1, prev;
  for (int i = 0; i < n; i++) {
    len = 1;
    prev = a[i];
    for (int j = i + 1; j < n; j++) {
      if (abs(a[j] - prev) <= k) {
        len++;
        prev = a[j];
      }
    }
    if (len > maxlen) maxlen = len;
  }
}
