a, lins = input().split()
coordinates = list(map(int, input().split()))
spaces = [0 for x in range(int(a))]

for i in range(int(a)):
    for j in range(int(a)):
        if abs(coordinates[i] - coordinates[j]) > int(lins):
            spaces[i]+=1
moda = [[0 for x in range(int(a))] for x in range(int(a))]
for i in spaces:
    for j in spaces:
        if i == j:
            moda[i][0] = i
            moda[i][1] +=1
maxValue = 0
for i in range(len(moda[:][1])):
    if moda[i][1] > maxValue:
        maxValue = moda[i][1]
        index = i
kick =0
for i in range(len(spaces)):
    if spaces[i] != moda[index][0]:
        kick +=1
print(kick)
