n, d = map(int, input().split())
s1 = input()
s = list(map(int, s1.split()))
s_res = [[] for i in range(n)]


s.sort()
for i in range(len(s)):
    for j in range(len(s)):
        if abs(int(s[j]) - int(s[i])) <= d and int(s[i]) <= int(s[j]):
            s_res[i].append(int(s[j]))

l = -1
for i in range(n):
    if len(s_res[i]) > l:
        l = len(s_res[i])

print(n - l)