n, d = [int(i) for i in input().split(" ")]
arr = [int(i) for i in input().split(" ")]

arr = sorted(arr)

res = n - max(j - i + 1 for i in range(n) for j in range(i, n) if arr[j] - arr[i] <=d)
print(res)