#include<cstdio>

int n, k, a[300010], lst, dis[300010];

template <class I> inline I abs(I x) {return x >= 0 ? x : -x;}
template <class I> inline I max(I a, I b) {return a > b ? a : b;}

inline bool cmp(int a, int b) {
	return abs(a - b) > k;
}

int main(void) {
	scanf("%d%d", & n, & k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", & a[i]);
	for (int i = 1; i <= n; ++i) {
		dis[i] = 1;
		for (int j = i - 1; i - j <= 100 && j >= 1; --j)
			if (abs(a[i] - a[j]) <= k && dis[j] + 1 > dis[i])
				dis[i] = dis[j] + 1;
	}
	for (int i = 1; i <= n; ++i)
		lst = max(lst, dis[i]);
	printf("%d\n", lst);
	return 0;
}