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