#include <bits/stdc++.h>
using namespace std;
int a[300005], b[300005];
int main() {
  int n, k, temp, res = 0, ms;
  cin >> n >> k;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    temp = i;
    ms = 1;
    for (int j = i + 1; j < n; j++) {
      if (abs(a[j] - a[temp]) <= k) {
        temp = j;
        ms++;
      }
    }
    res = max(res, ms);
  }
  cout << res;
  return 0;
}
