#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <atcoder/dsu.hpp>
#include <atcoder/mincostflow.hpp>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

int main()
{
	int N, K; cin >> N >> K;
	vector<int> as(N); REP(i, N) cin >> as[i];
	atcoder::dsu d(N);
	//atcoder::mcf_graph<int, int> graph(N + 2);
	//int s = N, g = N + 1;
	//REP(i, N)
	//{
	//	graph.add_edge(s, i, N, 1);
	//	graph.add_edge(i, g, N, 1);
	//}
	vector<bool> hasUsed(N, false);
	deque<int> Q{ 0 };
	hasUsed[0] = true;
	while (!Q.empty())
	{
		int v = Q.front(); Q.pop_front();
		for (int i = v + 1; i < N; ++i)
		{
			if (hasUsed[i]) continue;
			if (abs(as[v] - as[i]) <= K)
			{
				hasUsed[i] = true;
				Q.push_front(i);
				d.merge(v, i);
				break;
			}
			else
			{
				Q.push_back(i);
			}
		}
	}
	int ans = 0;
	for (const auto& group : d.groups())
	{
		ans = max(ans, static_cast<int>(group.size()));
	}
	cout << ans << endl;
}
