#include <bits/stdc++.h>
using namespace std;
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;
}
const int N = 100010;
int a[N], d1[N], n, k;
inline bool read(int& x) {
  char c = getchar();
  if (c == EOF) return false;
  while (c > '9' || c < '0') c = getchar();
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  n--;
  int len1 = 1;
  d1[1] = a[1];
  for (int i = 2; i <= n; i++) {
    if (abs(d1[len1] - a[i]) <= k)
      d1[++len1] = a[i];
    else
      *upper_bound(d1 + 1, d1 + 1 + len1, a[i], greater<int>()) = a[i];
  }
  printf("%d\n", len1 + 1);
  return 0;
}
