#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int index = 0; index < n; index++) cin >> arr[index];
  int ans = 0;
  for (int index = 0; index < n; index++) {
    int j = index;
    int curr = 1;
    int i = j + 1;
    while (i < n) {
      if (abs(arr[j] - arr[i]) <= k) {
        j = i;
        curr++;
      }
      i++;
    }
    ans = max(curr, ans);
  }
  cout << ans << endl;
  return 0;
}
