#include <bits/stdc++.h>
using namespace std;
const int maxn = 3 * 1e5 + 5;
int n, k;
vector<int> a(maxn);
vector<int> b(maxn, 0);
void nhap() {
  freopen("test.inp", "r", stdin);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
}
void solve() {
  int i = 1;
  int z = 2;
  b[1] = 1;
  b[2] = 1;
  for (int j = 3; j <= n; j++) {
    if (abs((long long)a[j] - a[z]) <= k) {
      b[j] = max(b[z] + 1, b[j]);
      z = j;
    } else if (abs((long long)a[j] - a[i]) <= k) {
      b[j] = max(b[i] + 1, b[j]);
      i = j;
    } else {
      b[j] = max(b[i], b[z]);
    }
  }
  cout << b[n];
}
int main() {
  nhap();
  solve();
}
