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