#include <algorithm>
#include <array>
#include <atcoder/all>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A(N, 0);
	rep(i, N) {
		cin >> A[i];
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int cnt = 1;
		for (int j = i; j < N; ++j) {
			for (int k = j + 1; k < N; ++k) {
				if (abs(A[k] - A[j]) <= K) {
					cnt++;
					j = k-1;
					break;
				}
			}
		}
		ans = max(ans, cnt);
	}

	cout << ans << endl;
	return 0;
}
