#include <bits/stdc++.h>
using namespace std;
bool com(pair<int, int> x, pair<int, int> y) { return x.first < y.first; }
int N = 1e5 + 9, k;
void input_() {}
std::vector<int> dp(N, -1);
int f(int i, int n, int k, int *a) {
  if (i == n - 1) return 1;
  if (dp[i] != -1) return dp[i];
  for (int j = i + 1; j < n; j++) {
    if (abs(a[i] - a[j]) <= k) {
      dp[i] = max(dp[i], 1 + f(j, n, k, a));
    }
  }
  return dp[i];
}
void solve() {
  int n, k;
  cin >> n >> k;
  int a[n];
  int ans = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (dp[i] == -1) ans = max(f(i, n, k, a), ans);
  }
  cout << ans;
}
int main() {
  input_();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
