#include <bits/stdc++.h>
using namespace std;
long long n, m, ans = 0;
long long f[500010], k[500010];
int main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> f[i];
    k[i] = 1;
  }
  for (long long i = 2; i <= n; i++) {
    for (long long j = i - 1; j >= 1; j--) {
      if (f[i] > f[j]) {
        if (f[i] - f[j] <= m) {
          k[i] = max(k[i], k[j] + 1);
        }
      } else {
        if (f[j] - f[i] <= m) {
          k[i] = max(k[i], k[j] + 1);
        }
      }
    }
    ans = max(ans, k[i]);
  }
  cout << ans << endl;
  return 0;
}
