n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
maximum = n-1
for i in range(n):
    for j in range(i+1,n):
        if(l[j]-l[i]<=k):
            if(n-(j-i+1)<maximum):
                maximum = n-(j-i+1)
print(maximum)
    