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