#include <bits/stdc++.h>
using namespace std;
long long n, k, a[300001];
long long vis[300001];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (long long i = 0; i < (n); i++) cin >> a[i];
  long long ans = -1e18;
  for (long long t = 0; t < (n); t++) {
    if (vis[t]) continue;
    long long cnt = 1, now = a[t];
    for (long long i = t + 1; i < (n); i++)
      if (labs(a[i] - now) <= k) {
        cnt++;
        now = a[i];
        vis[i] = 1;
      }
    ans = max(ans, cnt);
  }
  if (ans == -1e18) ans = 1;
  cout << ans << endl;
  return 0;
}
