#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(300000);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int dp[n + 1][n + 1];
  int maxa = 0;
  for (int i = 0; i < n; i++) {
    dp[i][i] = 1;
    int diff = a[i];
    for (int j = i + 1; j < n; j++) {
      if (abs(a[j] - diff) <= k) {
        dp[i][j] = dp[i][j - 1] + 1;
        diff = a[j];
      } else
        dp[i][j] = dp[i][j - 1];
    }
    maxa = max(maxa, dp[i][n - 1]);
  }
  cout << maxa << endl;
  return 0;
}
