#include <iostream>
#include <algorithm>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

int calc(int i, int j, vector<int>& A, int K) {
	if (i == 0) {
		return (j - K <= A[0] && A[0] <= j + K ? 1 : 0);
	}
	if (j - K <= A[i] && A[i] <= j + K) return max(1 + calc(i - 1, A[i], A, K), calc(i - 1, j, A, K));
	else return calc(i - 1, j, A, K);
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	cout << calc(N - 1, A[N - 1], A, K) << endl;
}
