n, d = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
ans = n
sw = 0
for i in range(n):
    s = a[i]
    for j in range(i+1, n):
        diff = a[j] - s
        if diff > d:
            ans = min(ans, n - j + i)
            sw = 1
            break
print ans  if sw else 0          
 