#include <bits/stdc++.h>
using namespace std;
int a[300005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i <= n - 1; i++) {
    cin >> a[i];
  }
  int count = 0, now, ans = -1;
  for (int i = 0; i <= n - 2; i++) {
    count = 1;
    now = a[i];
    for (int j = i + 1; j <= n - 1; j++) {
      if (abs(a[j] - now) <= k) {
        count++;
        now = a[j];
      }
    }
    ans = max(ans, count);
  }
  cout << ans << '\n';
  return 0;
}
