#include <bits/stdc++.h>
using namespace std;
long find(long a[], long n, vector<int> res, int curr, long k, int** dp) {
  if (curr == n) {
    return res.size();
  }
  if (dp[curr][res.size()] != -2) {
    return dp[curr][res.size()];
  }
  if (res.size() == 0 || abs(res[res.size() - 1] - a[curr]) <= k) {
    vector<int> temp = res;
    temp.push_back(a[curr]);
    long ans1 = find(a, n, temp, curr + 1, k, dp);
    long ans2 = INT_MIN;
    if (curr != 0) ans2 = find(a, n, res, curr + 1, k, dp);
    dp[curr][res.size()] = max(ans1, ans2);
    return dp[curr][res.size()];
  }
  vector<int> temp;
  temp.push_back(a[curr]);
  long ans1 = find(a, n, temp, curr + 1, k, dp);
  long ans2 = find(a, n, res, curr + 1, k, dp);
  dp[curr][res.size()] = max(ans1, ans2);
  return dp[curr][res.size()];
}
int main() {
  long n, k;
  cin >> n >> k;
  long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int** dp = new int*[n];
  for (int i = 0; i < n; i++) {
    dp[i] = new int[n + 1];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i][j] = -2;
    }
  }
  vector<int> res;
  long ans = find(a, n, res, 0, k, dp);
  cout << ans;
  for (int i = 0; i < n; i++) {
    delete[] dp[i];
  }
  delete[] dp;
}
