#!/usr/bin/python3

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

a = sorted(a)
i = 0
j = n-1
count = 0
while i < j:
    if a[j] - a[i] > d:
        if a[j-1] - a[i] <= d or a[j] - a[i+1] <= d:
            count += 1
            print(count)
            break
        if a[j-1] - a[i] > d:
            count += 1
            j -= 1
        if a[i+1] - a[j] > d:
            count += 1
            i += 1
    else:
        print(count)
        break
