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

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

array.sort()

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

i = 0
j = len(array)-1
count = 0
print(array)

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

    print(n-count)


