#include <bits/stdc++.h>
using namespace std;
void input() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int dp[n];
  dp[0] = 1;
  vector<int> v, v1;
  v.push_back(0);
  for (int i = 1; i < n; i++) {
    dp[i] = 1;
    int x, y = 1;
    for (auto it : v) {
      if (abs(a[i] - a[it]) <= k) {
        if (y < (dp[it] + 1)) {
          x = i;
          y = dp[it] + 1;
        }
      } else {
        v1.push_back(it);
      }
    }
    dp[i] = y;
    v1.push_back(x);
    v.clear();
    v = v1;
    v1.clear();
  }
  cout << dp[n - 1];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  input();
  return 0;
}
