#include <bits/stdc++.h>
using namespace std;
int f[300002], a[300002];
int ans = 0, n, k;
int main() {
  memset(f, sizeof(f), 0);
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  f[1] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < i; j++)
      if (abs(a[i] - a[j]) <= k) f[i] = max(f[i], f[j] + 1);
  for (int i = 1; i <= n; i++)
    if (ans < f[i]) ans = f[i];
  printf("%d", ans);
  return 0;
}
