n,d=map(int,input().split())
a=[int(x) for x in input().split()]
a.sort()
ans=0
j=n-1
ans=0
i=0
while a[j]-a[i]>d and j>0 and i<n-1:
	if a[j-1]-a[0]<=a[j]-a[i+1]:
		j-=1
	else:
		i+=1
	ans+=1
print(ans)