#include <bits/stdc++.h>
int N, K;
int* A;
int length(int i, int l) {
  if (i >= N) {
    return l;
  }
  int j = i;
  while (1) {
    j += 1;
    if (abs(A[j] - A[i]) <= K) {
      break;
    }
  }
  return length(j, l + 1);
}
int main() {
  scanf("%d%d", &N, &K);
  A = (int*)calloc(N, sizeof(int));
  for (int i = 0; i < N; i = i + 1) {
    scanf("%d", A + i);
  }
  int ans = 0;
  for (int i = 0; i < N; i = i + 1) {
    ans = ((ans) > (length(i, 0)) ? (ans) : (length(i, 0)));
  }
  printf("%d\n", ans);
  free(A);
  return 0;
}
