#include <bits/stdc++.h>
using namespace std;
template <typename T>
string join(vector<T> &vec, string &sp) {
  int si = vec.length;
  if (si == 0) {
    return "";
  } else {
    stringstream ss;
    for (int i = 0; i < (int)(si - 1); i++) {
      ss << vec[i] << sp;
    }
    ss << vec[si - 1];
    return ss.str();
  }
}
vector<int> uf(200010);
int root(int p) {
  if (p == uf[p])
    return p;
  else {
    return uf[p] = root(uf[p]);
  }
}
int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> vec[i];
  }
  vector<bool> v(n, true);
  int ma = 0;
  int sum = 0;
  int last = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (!v[i]) {
      continue;
    }
    last = vec[i];
    sum = 1;
    for (int j = i + 1; j < n; j++) {
      if (abs(last - vec[j]) <= k) {
        v[j] = false;
        sum++;
        last = vec[j];
      }
    }
    ma = max(ma, sum);
  }
  cout << ma << endl;
}
