n, d = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
while a[-1] - a[0] > d:
	if len(a) == 2:
		ans += 1
		break
	else:
		ans += 1
		if a[-1] - a[1] < a[-2] - a[0]:
			a = a[1:]
		else:
			a = a[:-1]
print(ans)