#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  vector<int> next(n, n);
  for (long long i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (abs(a[i] - a[j]) <= k) {
        next[i] = j;
        break;
      }
    }
  }
  int cur = 0;
  int ans = 0;
  vector<int> L(n, n);
  for (long long i = 0; i < n; ++i) {
    *lower_bound(L.begin(), L.end(), next[i]) = next[i];
  }
  ans = find(L.begin(), L.end(), n) - L.begin() + 1;
  cout << ans << endl;
  return 0;
}
