#include <bits/stdc++.h>
using namespace std;
int lis(vector<int>& arr, vector<vector<int>>& dp, int li, int i, int k) {
  if (li < 1 || i < 1) return 1;
  if (dp[i][li] != -1) return dp[i][li];
  if (abs(arr[i - 1] - arr[li - 1]) <= k) {
    return dp[i][li] = max(1 + lis(arr, dp, li - 1, li, k),
                           lis(arr, dp, i - 2, i - 1, k));
  }
  return dp[i][li] = lis(arr, dp, i - 2, i - 1, k);
}
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, dp, n - 1, n, k);
  cout << ans << endl;
  return 0;
}
