#include <bits/stdc++.h>
using namespace std;
long long int a, b;
vector<int> v(3000000);
long long int dp[3000000];
long long int goriberDP(long long int in) {
  if (in > a) return 0;
  if (dp[in] != -1) return dp[in];
  long long int mx = 0;
  for (long long int i = in + 1; i <= a; i++) {
    if (abs(v[in] - v[i]) <= b) mx = max(mx, 1 + goriberDP(i));
  }
  dp[in] = mx;
}
void solve() {
  cin >> a >> b;
  for (long long int i = 1; i <= a; i++) {
    cin >> v[i];
    dp[i] = -1;
  }
  long long int an = 1;
  for (long long int i = 1; i <= a; i++) {
    long long int t = 1 + goriberDP(i);
    an = max(an, t);
  }
  cout << an << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
