#include <bits/stdc++.h>
int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);
  int a[n - 1];
  for (int i = 1; i <= n; i++) scanf("%d", &a[i - 1]);
  int kiroku, koma, ans;
  ans = 1;
  for (int i = 1; i < n && (n - i) >= ans; i++) {
    kiroku = 1;
    koma = a[i - 1];
    for (int j = i; j < n; j++) {
      if (labs(koma - a[j]) <= k) {
        kiroku += 1;
        koma = a[j];
      }
    }
    if (kiroku > ans) ans = kiroku;
  }
  printf("%d", ans);
  return 0;
}
