#include <bits/stdc++.h>
using namespace std;
template <typename T>
T fact(T n) {
  return (n == 1 || n == 0) ? 1 : n * fact(n - 1);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
void dfs(vector<int> adj[], int s, bool vis[]) {
  vis[s] = true;
  for (int i = 0; i < adj[s].size(); i++) {
    if (vis[adj[s][i]] == false) {
      dfs(adj, adj[s][i], vis);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n];
  dp[0] = 1;
  for (int i = 1; i < n; i++) {
    int m = 0;
    for (int j = i - 1; j >= 0; j--) {
      if (abs(a[i] - a[j]) <= k) m = max(m, dp[j]);
    }
    dp[i] = 1 + m;
  }
  int ans = INT_MIN;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
  return 0;
}
