#include <bits/stdc++.h>
int n, k, a[300010], lst, dis[300010], pre[300010];
template <class I>
inline I abs(I x) {
  return x >= 0 ? x : -x;
}
template <class I>
inline I max(I a, I b) {
  return a > b ? a : b;
}
int main(void) {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    dis[i] = 1, pre[i] = -1;
    for (int j = i - 1; j >= 1; --j)
      if (abs(a[i] - a[j]) <= k && dis[j] + 1 > dis[i])
        pre[i] = j, dis[i] = dis[j] + 1;
  }
  for (int i = 1; i <= n; ++i) lst = max(lst, dis[i]);
  printf("%d\n", lst);
  return 0;
}
