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