#include <bits/stdc++.h>
using namespace std;
const int N = 300000 + 5;
int a[N];
int dp[N];
int n, k;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    dp[i] = 1;
    for (int j = 1; j <= i - 1; j++) {
      if (abs(a[i] - a[j]) <= k) dp[i] = max(dp[i], dp[j] + 1);
    }
  }
  cout << dp[n] << endl;
  ;
  system("pause");
  return 0;
}
