##
##   Contest : Codeforces Round #466 (Div. 2)
##   Problem : A. Points on the line
##
##    Author : Pranay Rycha
##      Date : 19-Apr-2020 ~ Sunday
##      Time : 12:47:50 PM
##

from os import path
if(path.exists('C:/Users/prana/Desktop/sublime/input.txt')):
	import sys
	sys.stdin = open("C:/Users/prana/Desktop/sublime/input.txt","r")
	sys.stdout = open("C:/Users/prana/Desktop/sublime/output.txt","w")

def solve(test_case):
	d=int(input().split()[1])
	a=list(map(int,input().split()))
	print(min(sum(1-(0<=c-p<=d)for c in a)for p in a))

test_case = 1
while(test_case):
	solve(test_case)
	test_case -= 1