


n, d = map(int, raw_input().strip().split())

arr = map(int, raw_input().strip().split())

def solve(arr, n, d):
    if n == 1:
        return 0

    arr.sort()

    i = len(arr) -1

    ans = 0
    while i > 0:
        if arr[i] - arr [0] <= d:
            return n - i - 1
        else:
            i -= 1
    if i == 0:
        return n


print solve(arr, n, d)