z,zz,dgraphs,mod=input,lambda:list(map(int,z().split())),{},10**9+7
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2))
def prime(x):
    p=ceil(x**.5)+1
    for i in range(2,p):
        if x%i==0 and x!=2:return 0
    return 1
def dfs(u,visit,graph):
    visit[u]=True
    for i in graph[u]:
        if not visit[i]:
            dfs(i,visit,graph)
################################################################################

"""

led=(6,2,5,5,4,5,6,3,7,6)

color4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]
19 3
5 4 10
"""

###########################---START-CODING---####################################

n,k=zz()
l=zz()

ans=7878788983898
for i in range(n):
    c=0
    x=l[i]
    
    for j in l:
        if  j-x<=k and j-x>=0:
            c+=1
    if ans>n-c:
        ans=n-c

print(ans)



 
