#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int res = 0;
  for (int i = 0; i < n - 1; ++i) {
    int m = 0;
    int min = i;
    for (int j = i + 1; j < n; ++j) {
      if (abs(a[i] - a[j]) <= k) {
        ++m;
        i = j;
      }
    }
    res = max(res, m);
    i = min;
  }
  cout << res + 1 << endl;
}
