#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 8;
const long long MOD = 1e9 + 7;
const long long LLINF = 1e18;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (long long i = long long(0); i < long long(n); i++) cin >> a[i];
  vector<int> cnt(n, -1);
  int ans = 0;
  for (long long i = long long(0); i < long long(n); i++) {
    int tmp = 1;
    if (cnt[i] != -1) continue;
    int prev = i;
    vector<int> mems;
    mems.push_back(i);
    cnt[i] = 0;
    for (int j = i + 1; j < n; ++j) {
      if (cnt[j] != -1) {
        tmp += cnt[j];
        break;
      } else if (abs(a[prev] - a[j]) <= k) {
        prev = j;
        cnt[j] = tmp;
        mems.push_back(j);
        ++tmp;
      }
    }
    for (int mem : mems) {
      cnt[mem] = tmp - cnt[mem];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
