n,r = map(int,input().split())
a = map(int,input().split())
flag = 0
a = sorted(a)
d = 0

for i in range(n):
    for j in range(i,n):
        if a[j] - a[i] <= r:
            d = max(d,j-i+1)
print(n-d)

					  	       					   		   	