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

            
