#include <bits/stdc++.h>
using namespace std;
int dp[300008][2];
int find(int a[], int k, int n, int ind, int prev) {
  if (ind >= n) return 0;
  if (abs(a[ind] - prev) <= k || prev == -1) {
    int ans1, ans2;
    if (dp[ind][0] != -1)
      ans1 = dp[ind][0];
    else {
      ans1 = 1 + find(a, k, n, ind + 1, a[ind]);
      dp[ind][0] = ans1;
    }
    if (dp[ind][1] != -1)
      ans2 = dp[ind][1];
    else {
      ans2 = find(a, k, n, ind + 1, prev);
      dp[ind][1] = ans2;
    }
    return max(ans1, ans2);
  } else {
    int ans2;
    if (dp[ind][1] != -1)
      ans2 = dp[ind][1];
    else {
      ans2 = find(a, k, n, ind + 1, prev);
      dp[ind][1] = ans2;
    }
    return ans2;
  }
}
int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[i][0] = -1;
    dp[i][1] = -1;
  }
  dp[n][0] = -1;
  dp[n][1] = -1;
  int ans = find(a, k, n, 0, -1);
  cout << ans;
  return 0;
}
