#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);
using namespace std;
void scans(string& str) {
  char c;
  str = "";
  scanf("%c", &c);
  if (c == '\n') scanf("%c", &c);
  while (c != '\n' && c != -1 && c != ' ') {
    str += c;
    scanf("%c", &c);
  }
}
void scanc(char& str) {
  char c;
  scanf("%c", &c);
  if (c == -1) return;
  while (c == '\n') {
    scanf("%c", &c);
  }
  str = c;
}
double acot(double x) { return PI / 2 - atan(x); }
ll LSB(ll n) { return (n & (-n)); }
template <typename T>
inline T chmin(T& a, const T& b) {
  if (a > b) a = b;
  return a;
}
template <typename T>
inline T chmax(T& a, const T& b) {
  if (a < b) a = b;
  return a;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &a[i]);
  }
  vector<int> dp(n);
  fill((dp).begin(), (dp).end(), -1);
  dp[0] = 0;
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (dp[j]) break;
      if (abs(a[j] - a[i]) <= k) chmax(dp[j], dp[i] + 1);
    }
  }
  printf("%d\n", dp[n - 1] + 1);
  return 0;
}
