#include <bits/stdc++.h>
using namespace std;
long long ash[100001];
long long f(long long a[], long long k, long long n, long long pp,
            long long start) {
  if (start == n) {
    return 1;
  }
  if (ash[start] != -1) return ash[start];
  if (abs(a[pp] - a[start]) <= k)
    return ash[start] = 1 + f(a, k, n, start, start + 1);
  else
    return ash[start] =
               max(f(a, k, n, pp, start + 1), f(a, k, n, start, start + 1));
}
int main() {
  memset(ash, -1, sizeof(ash));
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << f(a, k, n, 0, 1);
}
