n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
i, j, c = (0, len(a) - 1, 0)
while a[j] - a[i] > d:
    if (a[i + 1] - a[i]) > (a[j] - a[j-1]):
        i += 1
    else:
        j -= 1
    c += 1
print(c)
