#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N, K;
    cin>> N >> K;
    vi A(N);
    REP(i, 0, N) cin >> A[i];
    two_sat ts(N);
    REP(i, 0, N - 1){
        if(abs(A[i] - A[i+1]) < K && abs(A[i + 1] - A[i + 2]) < K){
            ts.add_clause(i, true, i + 1, true);
        }else if(abs(A[i] - A[i+1]) < K && abs(A[i + 1] - A[i + 2]) > K){
            ts.add_clause(i, true, i + 1, false);
        }else if(abs(A[i] - A[i+1]) > K && abs(A[i + 1] - A[i + 2]) < K){
            ts.add_clause(i, false, i + 1, true);
        }else if(abs(A[i] - A[i+1]) > K && abs(A[i + 1] - A[i + 2]) > K){
            ts.add_clause(i, false, i + 1, false);
        }
    }
    ts.satisfiable();
    auto answer = ts.answer();
    cout << answer.size() << endl;
}