n, d = map(int, input().split())

arr = list(map(int, input().split()))

ans = 0

arr.sort()

for i in range(len(arr)):

    j = i + 1
    while j < len(arr):
        if abs(arr[i] - arr[j]) > d:
            num = max(arr[i], arr[j])
            arr.remove(num)
            ans += 1
            j -= 1
        j += 1

print(ans)
        
