#include <bits/stdc++.h>
using namespace std;
long long dp[300001];
long long n;
long long k;
long long arr[300001];
long long solve(long long i, long long j) {
  if (dp[i] != -1) return dp[i];
  if (i == n) {
    if (abs(arr[i] - j) <= k)
      return 1;
    else
      return 0;
  }
  if (abs(arr[i] - j) > k)
    dp[i] = solve(i + 1, j);
  else
    dp[i] = max(1 + solve(i + 1, arr[i]), solve(i + 1, j));
  return dp[i];
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    dp[i] = -1;
  }
  cout << solve(1, arr[1]) << endl;
  return 0;
}
