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