#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int counter = 1;
  int tmp;
  vector<int> input;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    input.emplace_back(tmp);
  }
  int max = 1;
  int before = 0;
  for (int i = 0; i < n; i++) {
    before = input[i];
    for (int j = i + 1; j < n; j++) {
      if (abs(before - input[j]) <= k) {
        before = input[j];
        counter++;
      }
    }
    if (max < counter) max = counter;
    if (n - i < max) break;
    if (max > n / 2) break;
    counter = 0;
  }
  cout << max;
}
