#include <bits/stdc++.h>
#include <atcoder/twosat>
#include <iostream>
#include <vector>

using namespace std;
using namespace atcoder;

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll N,K;
    string S;
    cin >> N>>K;

    vector<ll> A(N),B(N);
    REP(i, N){
        cin >> A.at(i);
    }

    REP(i,N-1){
        B.at(i+1) = A.at(i);
    }
    B.at(0) = A.at(N - 1);

    two_sat ts(N);

    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            if (abs(A[i] - A[j]) < K)
            {
                // cannot use both of x[i] and x[j]
                ts.add_clause(i, true, j, true);
            }
            if(abs(A[i] - B[j])<K)
            {
                ts.add_clause(i, true, j, false);
            }
            if (abs(B[i] - A[j]) < K)
            {
                ts.add_clause(i, false, j, true);
            }
            if(abs(B[i] - B[j])<K){
                ts.add_clause(i, false, j, false);
            }
        }
    }

    ll count = 0;

    if(!ts.satisfiable()){
        cout << 0 << endl;
    }
    else{
        auto ans = ts.answer();
        REP(i,N){
            if (ans[i] == true)
            {
                count++;
            }
        }

        cout << count << endl;
    }
}
