#include <bits/stdc++.h>
using namespace std;
long long int mod_pow(long long int a, long long int b, long long int m) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
vector<vector<long long int>> adj(1000000);
vector<bool> vis(1000000, false);
void dfs(long long int u) {
  vis[u] = true;
  for (auto x : adj[u])
    if (!vis[x]) dfs(x);
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n);
  vector<long long int> dp(n, 1);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < i; j++)
      if (abs(a[i] - a[j]) <= k) dp[i] = max(dp[i], dp[j] + 1);
  }
  cout << dp[n - 1];
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int q;
  q = 1;
  while (q--) solve();
  return 0;
}
