
n,d=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
l=sorted(l)
c=0
z=l[n-1]-l[0]
while z>d:
	c+=1
	if l[1]-l[0] > l[-1]-l[-2]:
		l.pop(0)
	else:
		l.pop(-1)
	z=l[-1]-l[0]
print (c)