#include <bits/stdc++.h>
using namespace std;
long long int n, a[1000000], k, dp[1000000];
int cal[1000000] = {0};
long long int findlength(long long int t) {
  dp[n - 1] = 1;
  cal[n - 1] = 1;
  if (cal[t] == 1) return dp[t];
  if (t == n - 1)
    return 1;
  else {
    long long int max1 = 0;
    for (long long int i = t + 1; i < n; i++) {
      if (abs(a[t] - a[i]) <= k) {
        long long int s = findlength(i);
        if (s > max1) max1 = s;
      }
    }
    cal[t] = 1;
    dp[t] = max1 + 1;
    return dp[t];
  }
}
int main() {
  cin >> n >> k;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int max1 = 0;
  for (long long int i = 0; i < n; i++) {
    long long int temp = findlength(i);
    if (temp > max1) max1 = temp;
  }
  cout << max1;
  return 0;
}
