import sys
n, d = [int(x) for x in input().split()]
lst = [int(x) for x in input().split()]
lst.sort()
z = 0
if max(lst)-min(lst)==d:
        print(0)
        sys.exit()
for i in range(n):
        for j in range(i+1,n+1):
                lst1 = lst[i:j]

                if max(lst1)-min(lst1)<=d and z<=len(lst1):
                        z=len(lst1)
print(n-z)
