#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < n - ans; i++) {
    int cnt = 1;
    for (int j = i; j < n - 1; j++) {
      int plus = 0;
      if (abs(a[j + 1] - a[j]) <= k)
        cnt++;
      else {
        while (1) {
          if (abs(a[j + 1 + plus] - a[j]) <= k) {
            j += plus;
            cnt++;
            break;
          } else
            plus++;
        }
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}
