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