# -*- coding:utf-8 -*-
num_sum,d = map(int,raw_input().strip().split(" "))
all = map(int,raw_input().strip().split(" "))
if len(all)<1:
    print 0
all = sorted(all)
res=0
search_num = num_sum/2
head=0
tail=len(all)-1
while(True):
    if (all[tail]-all[head]) > d:
        res+=1
    else:
        break
    tail-=1
print res