def solve():
    N, d = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort()

    count = 0
    while True:
        if L[-1] - L[0] <= d:
            print(count)
            return
        else:
            if L[-1] - L[-2] >= L[1] - L[0]:
                L = L[:-1]
            else:
                L = L[1:]
            count += 1



if __name__ == "__main__":
    solve()


