#include <bits/stdc++.h>
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};
const int INF = 1e9 + 5;
using namespace std;
int n, m, u, v;
int memo[110000];
bool fl[110000];
vector<int> eg[110000];
int dp(int v) {
  if (fl[v]) {
    return memo[v];
  }
  int ans = 0;
  for (int to : eg[v]) {
    ans = max(ans, dp(to) + 1);
  }
  fl[v] = true;
  memo[v] = ans;
  return ans;
}
struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int Find(int x) {
    if (d[x] < 0) return x;
    return d[x] = Find(d[x]);
  }
  bool unite(int x, int 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(int x, int y) { return Find(x) == Find(y); }
  int size(int x) { return (-d[Find(x)]); }
};
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n), dp(n);
  dp[0] = 1;
  for (int i = (int)(0); i < (int)(n); ++i) {
    cin >> vec[i];
  }
  for (int i = (int)(0); i < (int)(n); ++i) {
    if (i == 0) continue;
    int j = i - 1;
    bool fl1 = false, fl2 = false;
    while (0 <= j) {
      if (abs(vec[i] - vec[j]) <= k && vec[i] - vec[j] < 0) {
        dp[i] = max(dp[j] + 1, dp[i]);
        fl1 = true;
      }
      if (abs(vec[i] - vec[j]) <= k && vec[i] - vec[j] >= 0) {
        dp[i] = max(dp[j] + 1, dp[i]);
        fl2 = true;
      }
      if (fl1 && fl2) {
        break;
      }
      j--;
    }
  }
  cout << dp[n - 1] << endl;
}
