#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int K;
  cin >> N >> K;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    int temp = A[i];
    int xed = 0;
    for (int j = i + 1; j < N; j++) {
      if (abs(temp - A[j]) <= K) {
        xed++;
        temp = A[j];
      }
    }
    res = max(res, xed);
  }
  if (res != 0) {
    res++;
  }
  cout << res;
  return 0;
}
