#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int len = 0;
    int a = i, b = i + 1;
    while (a < N && b < N) {
      if (abs(A[a] - A[b]) <= K) {
        len++;
        a = b;
        b++;
      } else
        b++;
    }
    ans = std::max(len, ans);
  }
  cout << ans + 1;
  return 0;
}
