from collections import defaultdict
n, d = map(int, raw_input().split(" "))
inp = sorted(map(int, raw_input().split(" ")))
p = defaultdict(int)
while True:
    nn = len(inp)
    p.clear()
    for i in range(nn):
        for j in range(i+1, nn):
            if i == j:
                continue
            if abs(inp[i] - inp[j]) > d:
                p[inp[i]] += 1
                p[inp[j]] += 1
    if len(p) == 0:
        break
    pmax = max(p.values())
    for k,v in p.iteritems():
        if v == pmax:
            while k in inp:
                inp.remove(k)
            break
print n - len(inp)
        
