#include <bits/stdc++.h>
using namespace std;
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int N = 3e5 + 23;
int a[N], dp[N], tail[N];
void solve() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  vector<int> tail(1, a[0]);
  for (int i = 0; i < n; ++i) {
    if (a[i] < tail[0])
      tail[0] = a[i];
    else if (abs(a[i] - tail.back()) <= k)
      tail.push_back(a[i]);
    else
      *upper_bound(tail.begin(), tail.end(), a[i]) = a[i];
  }
  printf("%d", tail.size() - 1);
}
int main() {
  init();
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
