n,d=map(int,input().split())
cords=[]

inp = input()
inp = inp.split(" ")
inp = list (inp)

for ele in inp:
    cords.append(int(ele))

cords = sorted (cords,reverse=True)
value = 0
counter = 0
for i in range (len(cords)):
    counter=0
for ele in cords :
    if (ele - cords[len(cords)-1-i]) != d :
       counter+=1
    else:
        value = 10
        break
    if(value == 10):
        break

print(counter)
