def multi():
    inp = input().split(" ")
    k, d = int(inp[0]), int(inp[1])
    l = list(map(int, input().split(" ")))
    result = len(l)
    l.sort()
    for i in range(0, len(l)):
        for j in range(len(l) - 1, i - 1, -1):
            diam = abs(l[i] - l[j])
            if diam <= d:
                subResult = len(l) - (j - i + 1)
                if result > subResult:
                    result = subResult
                    break
    print(result)
    return

multi()