from functools import *
from time import time


def measure_time(fun):
    def wrapper(*args, **kwargs):
        begin = time()
        rv = fun(*args, **kwargs)
        end = time()
        print(end - begin)
        return rv
    return wrapper


def our_cache(func):
    memo = [-1]*(max+1)

    @wraps(func)
    def wrapper(arg):
        if memo[arg] == -1:
            memo[arg] = func(arg)
        return memo[arg]
    return wrapper


def main():
    n, d = [int(x) for x in input().split()]
    arr = [int(x) for x in input().split()]
    max_l = 0
    for i in arr:
        l = 0
        for j in arr:
            if 0 <= j-i <= d:
                l += 1
        max_l = max(max_l, l)
    print(len(arr) - max_l)


if __name__ == "__main__":
    main()