N,K = map(int,input().split())

A = [None]*N

for i in range(N):
    A[i] = int(input(""))
    
flag = 0
cnt  = 0

for i in range(N):
    for j in range(i+1,N):
        if abs(A[i]-A[j]) <= K:
            if flag == 0:
                flag += 1
            else:
                cnt += 1
                flag = 0
                break

print(cnt)