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