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