#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, k;
int a[300010];
int dp[300010][2];
vector<int> ans;
int main() {
  cin >> n >> k;
  for (long long i = 0; i < (n); i++) {
    cin >> a[i];
    dp[i][0] = dp[i][1] = -100000007;
  }
  dp[0][0] = 0;
  dp[0][1] = 1;
  for (long long i = (1); i < (n); i++) {
    dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
    long long now = -1;
    long long maxx = -1e9;
    for (long long j = i - 1; j >= 0; j--) {
      long long x = max(dp[j][0], dp[j][1]);
      if (a[i] - k <= a[j] && a[i] + k >= a[j] && x > maxx) {
        now = j;
        maxx = x;
      }
    }
    if (now == -1) {
      dp[i][1] = 1;
    } else {
      dp[i][1] = maxx + 1;
    }
  }
  cout << max(dp[n - 1][0], dp[n - 1][1]);
  return 0;
}
