#include <bits/stdc++.h>
using namespace std;
int A[300010];
int dp[300010];
int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int maxcnt = 0;
  int cnt = 0;
  int temp = 0;
  for (int i = 0; i < N; i++) {
    cnt = 1;
    if (dp[i] == 1) {
      break;
    }
    temp = A[i];
    for (int j = i; j < N - 1; j++) {
      if (abs(temp - A[j + 1]) <= K) {
        cnt++;
        dp[j + 1] = 1;
        temp = A[j + 1];
      }
    }
    maxcnt = max(maxcnt, cnt);
  }
  cout << maxcnt << endl;
  return 0;
}
