a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
if(a==1):
	print(0)
else:	
	d=[]
	for i in range(a-1):
		x=c[i]+b
		j=i+1
		k=0
		while(j<a and c[j]<=x ):
			k+=1
			j+=1
		d.append(k)	
	print(a-max(d)-1)		
	
