#include <bits/stdc++.h>
using namespace std;
long long powm(long long a, long long b, long long mod) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    long long tmp = powm(a, b / 2, mod);
    return (tmp * tmp) % mod;
  } else
    return (a % mod * powm(a, b - 1, mod)) % mod;
}
long long invm(long long a, long long mod) { return powm(a, mod - 2, mod); }
long long mod = 1000000007;
void solve() {
  int n, k;
  cin >> n >> k;
  int a[n], ret = 1;
  for (int &i : a) cin >> i;
  vector<int> dp(n, 1);
  for (int i = 0; i < n; i++) {
    int tmp = 1;
    for (int j = i - 1; j >= 0; j--) {
      if (abs(a[i] - a[j]) <= k) tmp = max(tmp, 1 + dp[j]);
    }
    dp[i] = tmp;
    ret = max(ret, tmp);
  }
  cout << ret << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(12);
  long long t = 1, tc = 1;
  while (t--) {
    solve();
  }
  return 0;
}
