#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  vector<int> A(N);
  for (int i = 0; i < (N); ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < (N); ++i) {
    vector<int> B;
    B.push_back(A[i]);
    int j = i + 1;
    while (j < N) {
      int now = A[i];
      int next = A[j];
      if (abs(now - next) <= K) {
        B.push_back(next);
        i = j;
        j++;
      } else {
        j++;
      }
    }
    int l = B.size();
    ans = max(ans, l);
  }
  cout << ans << endl;
}
