#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long int i = 0, j = 1, n, m, x, a[300010], dp, k, l = 0, saisyo = 0;
  string s;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    j = 0;
    dp = a[i];
    for (l = i + 1; l < n; l++) {
      if (abs(dp - a[l]) <= k) {
        j++;
        dp = a[i];
      }
    }
    if (j > saisyo) {
      saisyo = j;
    }
  }
  cout << saisyo << endl;
  return 0;
}
