n, d = map(int, raw_input().split(" "))
inp = map(int, raw_input().split(" "))
_max = max(inp)
_min = min(inp)
while _max - _min > d:
    if inp.count(_max) > inp.count(_min):
        target = _min
    else:
        target = _max
    while target in inp:
        inp.remove(target)
    _max = max(inp)
    _min = min(inp)
print n - len(inp)
