a=input().split()
a[1]=int(a[1])
b=input().split()
counter=0
for i in range(len(b)):
    b[i]=int(b[i])
b.sort()
while(True):
    if(abs(b[0]-b[len(b)-1]) <a[1] or abs(b[0]-b[len(b)-1])==a[1] ):
        print(counter)
        break
    else:
        if(b.count(b[0]))==(b.count(b[len(b)-1])):
            b=list(filter(lambda a: a != b[len(b)-1], b))
            counter+=b.count(b[len(b)-1])
        elif((b.count(b[0]))<(b.count(b[len(b)-1]))):
            b=list(filter(lambda a: a != b[0], b))
            counter+=b.count(b[0])
        else:
            b=list(filter(lambda a: a != b[len(b)-1], b))
            counter+=b.count(b[len(b)-1])
    
