#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int a[N] = {0};
int max_length[N];
int ans = 0;
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int j = 1; j < n; j++) {
    int now = a[j];
    int sum = 0;
    for (int i = j; i <= n; i++) {
      if (abs(a[i] - now) <= k) {
        sum++;
        now = a[i];
      }
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
