#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n;
  cin >> n >> k;
  int num[30005] = {};
  int T[30005] = {};
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }
  int ans = 0;
  int end = 0;
  while (end != n) {
    int h = 0;
    int temp;
    for (int i = 0; i < n; i++) {
      if (T[i] != 0)
        ;
      else {
        if (h == 0) {
          temp = num[i];
          h++;
          T[i] = 1;
          end++;
        } else {
          if (abs(temp - num[i]) <= k) {
            temp = num[i];
            h++;
            T[i] = 1;
            end++;
          }
        }
      }
    }
    ans = max(ans, h);
  }
  cout << ans;
}
