#include <bits/stdc++.h>
using namespace std;
struct XX {
  int x;
  int y;
  int i;
  int ans;
};
class xxGreater {
 public:
  bool operator()(const XX& riLeft, const XX& riRight) const {
    if ((riLeft.x) == (riRight.x)) {
      return riLeft.y < riRight.y;
    }
    return (riLeft.x) < (riRight.x);
  }
};
int main(int argc, const char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int a[300000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int mini = n;
  for (int p = 0; p < mini; p++) {
    int tmp = 0;
    int f = 0;
    int prev = a[p];
    for (int i = p; i < n; i++) {
      if (abs(prev - a[i]) <= k) {
        if (f == 0 && i != p) {
          mini = min(mini, i);
          f = 1;
        }
        tmp++;
        prev = a[i];
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
