#include <bits/stdc++.h>
using namespace std;
const int N = 300001;
int n, m, k;
int a[N];
map<pair<int, int>, int> dp;
int solve(int i, int lastIndx) {
  if (i > n) return 0;
  if (dp[{i, lastIndx}] != 0) return dp[{i, lastIndx}];
  int ans1 = solve(i + 1, lastIndx), ans2 = 0;
  if (abs(a[i] - a[lastIndx]) <= k) ans2 = solve(i + 1, i) + 1;
  return dp[{i, lastIndx}] = max(ans1, ans2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << solve(0, 0) << endl;
  return 0;
}
