n , d = [int(c) for c in input().split()]
a = [int(x) for x in input().split()]

a.sort()
cnt = 0
ans = n - 1

for i in range(n - 1):
    cnt = 0
    for j in range(i + 1, n):
        if a[j] - a[i] > d:
            cnt += 1
    #print('for', a[i], cnt)
    ans = min(ans, cnt)
            
print(ans)
