#include <bits/stdc++.h>
using namespace std;
void tie() {
  ios::sync_with_stdio(0);
  cin.tie(0);
}
int main() {
  tie();
  int ans = 0;
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int start = 0; start < n - 1; start++) {
    int cnt = 0, last = a[start];
    for (int i = start; i < n; i++) {
      if (abs(last - a[i]) <= k) {
        last = a[i], cnt++;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans;
  return 0;
}
