import sys as sys    
import math as math

mn = map(int,sys.stdin.readline().split())

n = mn[0]
d =  mn[1]

b = map(int,sys.stdin.readline().split())

b.sort()

ne = n
nb = 0
st = 0


while b[ne-1]-b[nb] > d:
    st = st+1
    if b[ne-2]-b[nb] < b[ne-1]-b[nb-1]:
		ne = ne-1
    if b[ne-2]-b[nb] > b[ne-1]-b[nb-1]:
	    nb = nb+1

print st
