n,d = map(int,raw_input().split())
a = map(int,raw_input().split())
a.sort()
rem = 0
l = 0
r = n-1
while l<r:
	if a[r]-a[l]>d:
		if(d-a[l]>a[r]-d):
			l+=1
		else:
			r -= 1
		rem += 1
	elif a[r]-a[l]<=d:
		break;
print rem