l = input()
n, d = l.split()
n = int(n)
d = int(d)
l = input()
l = l.split()
for i in range(0,n):
	l[i] = int(l[i])
l.sort()

while(1):
	temp = l[0]
	cnt1 = 0
	for i in range(1,len(l)):
		if(l[i]-temp > d):
			cnt1 = cnt1+1
	temp = l[len(l)-1]
	cnt2 = 0
	for i in range(0,len(l)-1):
		if(temp-l[i] > d):
			cnt2 = cnt2+1
	if(cnt1 == 0 and cnt2 == 0):
		break
	if(cnt2 > cnt1):
		del l[len(l)-1]
	else:
		del l[0]
print(n-len(l))