#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
long long int i, j, n, m, k, ans;
long long int a[300000];
bool checked[300000];
int main() {
  scanf(" %lld %lld", &n, &k);
  for (i = 0; i < n; i++) {
    scanf(" %lld", &a[i]);
    checked[i] = false;
  }
  long long int ans = 1;
  for (j = 0; j < n; j++) {
    if (checked[j]) continue;
    long long int prev = a[j];
    long long int anstmp = 1;
    checked[0] = true;
    for (i = j + 1; i < n; i++) {
      if (abs(a[i] - prev) <= k) {
        prev = a[i];
        anstmp++;
        checked[i] = true;
      }
    }
    if (ans <= anstmp) ans = anstmp;
  }
  printf("%lld\n", ans);
}
