n, r = map(int, input().split())
dots = list(map(int, input().split()))
dots.sort()
max = 0
for num in range(len(dots)):
    local = 0
    for num2 in range(num, len(dots)):
        if abs(dots[num] - dots[num2]) <= r:
            local += 1
        else:
            break
    if local > max:
        max = local

print(n - max)
