n,k=map(int,input().split())
l=sorted(list(map(int,input().split())))
l.append(1000000)
a=[]
for i in range(n+1):
	u=1
	for j in range(i+1,n+1):
		if l[j]-l[i]<=k:
			u+=1
		else:
			a.append(u)
			u=0  
print(n-max(a))
		
			