noe, maxs = [int(x) for x in input().split()]
arr1 = [int(x) for x in input().split()]
arr = sorted(arr1)
mins = int(10e9)
for i in range(noe):
    for j in range(i, noe):
        if arr[j]-arr[i] <= maxs:
            if noe - j + i - 1 < mins:
                mins = noe - j + i - 1
print(mins)