def find_maxdiff(xs, d):
    maxdiff_idx = 0
    diffs = [0 for i in range(len(xs))]
    for i in range(len(xs)-1):
        for j in range(i+1, len(xs)):
            if abs(xs[i] - xs[j]) > d:
                for s in (i, j):
                    diffs[s] += 1
                    if diffs[s] > diffs[maxdiff_idx]:
                        maxdiff_idx = s

    return maxdiff_idx if diffs[maxdiff_idx] else None


def main():
    n, d = [int(x) for x in input().split()]
    xs = [int(x) for x in input().split()]

    count = 0
    maxdiff_idx = find_maxdiff(xs, d)
    while maxdiff_idx is not None:
        count += 1
        xs.pop(maxdiff_idx)
        maxdiff_idx = find_maxdiff(xs, d)

    print(count)


main()
