#include <bits/stdc++.h>
using namespace std;
const double pie = acos(-1.0);
template <typename T>
T Max(T x, T y) {
  return (x > y) ? x : y;
}
template <typename T>
T Min(T x, T y) {
  return (x > y) ? y : x;
}
int gcd(int n1, int n2) {
  if (n2 != 0)
    return gcd(n2, n1 % n2);
  else
    return n1;
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
clock_t time_p = clock();
void rtime() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)1000 * (time_p) / CLOCKS_PER_SEC << "\n";
}
long long int ans(long long int dp[][2], long long int arr[], long long int n,
                  long long int r) {
  if (n <= 0) return 0;
  long long int t1, t2;
  if (dp[n - 1][r] != -1) return dp[n - 1][r];
  if (r == 0) {
    t1 = arr[n - 1] + ans(dp, arr, n - 1, 1);
    t2 = ans(dp, arr, n - 1, 0);
  } else {
    t1 = ans(dp, arr, n - 1, 0) - arr[n - 1];
    t2 = ans(dp, arr, n - 1, 1);
  }
  dp[n - 1][r] = Max(t1, t2);
  return dp[n - 1][r];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int dp[n];
  int max = 0;
  for (int i = 0; i < n; i++) {
    dp[i] = 1;
    for (int j = i - 1; j >= 0; j--) {
      if (abs(arr[i] - arr[j]) <= k) {
        dp[i] = Max(dp[i], dp[j] + 1);
      }
    }
    if (dp[i] > max) max = dp[i];
  }
  cout << max;
}
