#include <bits/stdc++.h>
using namespace std;
int a[3000000];
int dp[3000000][2];
int main() {
  int n, k, j = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][0]);
    if (abs(a[i] - a[j]) <= k) {
      dp[i][1] = max(dp[i - 1][1] + 1, dp[i - 1][0] + 1);
      j = i;
    }
  }
  cout << max(dp[n][0], dp[n][1]);
  return 0;
}
