from sys import stdin
from collections import *


def arr_inp(n):
    if n == 1:
        return [int(x) for x in stdin.readline().split()]
    elif n == 2:
        return [float(x) for x in stdin.readline().split()]
    else:
        return list(stdin.readline()[:-1])


n, d = arr_inp(1)
x, ans = deque(sorted(arr_inp(1))), 0

while x:
    if x[-1] - x[0] <= d:
        break
    else:
        if len(x) <= 2:
            ans += 1
            break
        else:
            if x[-2] - x[0] <= x[-1] - x[1]:
                x.pop()
            else:
                x.popleft()
            ans += 1
print(ans)
