#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const long long LINF = 1e18;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc, k;
  cin >> tc >> k;
  int arr[tc];
  for (int t = 0; t < tc; t++) {
    cin >> arr[t];
  }
  int dp[tc];
  int maxval = 1;
  for (int i = 0; i < tc; i++) {
    dp[i] = 1;
    for (int j = i - 1; j >= 0; j--) {
      if (abs(arr[j] - arr[i]) <= k) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
    maxval = max(maxval, dp[i]);
  }
  cout << maxval;
}
