
#k=int(input())
#n,m=map(int,input().split())

#a=list(map(int,input().split()))

#b=list(map(int,input().split()))


n,d=map(int,input().split())
a=list(map(int,input().split()))

a.sort()

m=-1
for i in range(n):
    for j in range(i,n):
        if a[j]-a[i]<=d and m<j-i+1:
            m=j-i+1

print(n-m)