a = list(map(int, input().split()))

array = list(map(int, input().split()))

array.sort()

n = a[0]
d = a[1]

count = 0

for i in range(0, len(array)):
    for j in range(i, len(array)):
        if array[j] - array[i] <= d:
            count = max(count, j - i + 1)


print(n - count)

