#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, x, c = 0;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> v;
  for (int i = 0; i < n; i++) {
    x = a[i];
    c = 1;
    for (int j = i + 1; j < n; j++) {
      if (abs(x - a[j]) <= k) {
        c++;
        x = a[j];
      }
    }
    v.push_back(c);
    if (c == n) break;
  }
  sort(v.begin(), v.end());
  if (v.size() > 0)
    cout << v[v.size() - 1] << endl;
  else
    cout << 0 << endl;
}
