#include <bits/stdc++.h>
using namespace std;
int mapa[312345];
int main() {
  int nun_c, nun_l, res = 0, vet[112345], x = 0, atual;
  scanf("%d%d", &nun_c, &nun_l);
  for (int i = 0; i < nun_c; i++) {
    scanf("%d", &vet[i]);
  }
  for (int i = 0; i < nun_c; i++) {
    if (!mapa[i]) {
      x = 0;
      atual = vet[i];
      mapa[i] = 1;
      for (int j = i + 1; j < nun_c; j++) {
        if (abs(atual - vet[j]) <= nun_l) {
          x++;
          atual = vet[j];
          mapa[j] = 1;
        }
      }
      if (x + 1 > res) {
        res = x + 1;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}
