#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<int> dp(n + 1, 0);
  if (abs(arr[0] - arr[1]) <= k)
    dp[1] = 2;
  else
    dp[1] = 1;
  dp[0] = 1;
  for (int i = 2; i < n; i++) {
    int temp = 0;
    for (int j = 0; j < i; j++) {
      if (abs(arr[j] - arr[i]) <= k) temp = max(temp, dp[j] + 1);
    }
    dp[i] = temp;
  }
  cout << dp[n - 1] << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
