#include <bits/stdc++.h>
using namespace std;
int n, a[300005], dp[300005], v[300005 << 2], k;
void Insert(int n, int L, int R, int l, int r, int k) {
  if (l <= L && r >= R) {
    v[n] = max(v[n], k);
    return;
  }
  int mid = (L + R) >> 1;
  if (l <= mid) Insert(n << 1, L, mid, l, r, k);
  if (r > mid) Insert(n << 1 | 1, mid + 1, R, l, r, k);
  v[n] = max(v[n << 1], v[n << 1 | 1]);
  return;
}
int query(int n, int L, int R, int l, int r) {
  if (l <= L && r >= R) return v[n];
  int mid = (L + R) >> 1;
  int ret = -1;
  if (l <= mid) ret = max(ret, query(n << 1, L, mid, l, r));
  if (r > mid) ret = max(ret, query(n << 1 | 1, mid + 1, R, l, r));
  ;
  return ret;
}
int main() {
  memset(v, -1, sizeof(v));
  scanf("%d%d", &n, &k);
  int h = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    h = max(h, a[i]);
  }
  dp[0] = 1;
  Insert(1, 0, h, a[0], a[0], dp[0]);
  for (int i = 1; i < n; i++) {
    int c = query(1, 0, h, max(0, a[i] - k), a[i] + k);
    if (c == -1) c = 0;
    dp[i] = c + 1;
    Insert(1, 0, h, a[i], a[i], dp[i]);
  }
  printf("%d\n", dp[n - 1]);
  return 0;
}
