#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int ans = 1;
  cin >> a.at(0);
  int temp = a.at(0);
  for (int i = 1; i < n; i++) {
    cin >> a.at(i);
    if (abs(temp - a.at(i)) <= k) {
      temp = a.at(i);
      ans++;
    }
  }
  int ans2 = 1;
  for (int i = 2; i < n; i++) {
    if (n - i + 1 >= ans) {
      temp = a.at(i);
      for (int j = i + 1; j < n; j++) {
        if (abs(temp - a.at(j)) <= k) {
          temp = a.at(j);
          ans2++;
        }
      }
      if (ans2 > ans) {
        ans = ans2;
      }
    }
  }
  cout << ans << endl;
}
