#include <bits/stdc++.h>
using namespace std;
using vec = vector<long long>;
long long facctorialMethod(long long k);
long long modpow(long long a, long long n, long long mod);
long long gcd(long long a, long long b);
long long lcm(long long a, long long b);
struct UnionFind {
  vector<long long> d;
  UnionFind(long long n = 0) : d(n, -1) {}
  long long find(long long x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(long long x, long long y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(long long x, long long y) { return find(x) == find(y); }
  long long size(long long x) { return -d[find(x)]; }
};
int main() {
  int clock_on = 0;
  int time_clock = clock();
  long long N, K, output;
  cin >> N >> K;
  vector<long long> A(N + 1);
  for (long long i = 0; i < (N); i++) {
    cin >> A.at(i + 1);
  }
  vector<long long> dp(N + 1, 0);
  dp.at(1) = 0;
  long long mininf = -1000000;
  for (long long i = 2; i < (N + 1); i++) {
    for (long long j = 1; j < (i); j++) {
      if (abs(A.at(i) - A.at(j)) <= K) {
        dp.at(i) = max(dp.at(i), dp.at(j) + 1);
      }
    }
    output = max(output, dp.at(i));
  }
  cout << output + 1 << endl;
  if (clock_on == 1)
    printf("Execution Time: %.4lf sec\n",
           1.0 * (clock() - time_clock) / CLOCKS_PER_SEC);
  return 0;
}
long long facctorialMethod(long long k) {
  long long sum = 1;
  for (long long i = 1; i <= k; ++i) {
    sum *= i;
  }
  return sum;
}
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
