#include <bits/stdc++.h>
using namespace std;
int lis(vector<int>& arr, int prevInd, int last, vector<vector<int>>& t,
        int k) {
  if (last < 0) return 0;
  if (t[prevInd + 1][last] != -1) return t[prevInd + 1][last];
  int prevVal;
  if (prevInd == -1)
    prevVal = arr[last] + k;
  else
    prevVal = arr[prevInd];
  int taken = 0, nottaken;
  if (abs(arr[last] - prevVal) <= k) {
    taken = 1 + lis(arr, last, last - 1, t, k);
  }
  nottaken = lis(arr, prevInd, last - 1, t, k);
  return t[prevInd + 1][last] = max(taken, nottaken);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  vector<vector<int>> dp(n + 1, vector<int>(n + 1, -1));
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = lis(arr, -1, n - 1, dp, k);
  cout << ans << endl;
  return 0;
}
