k = 0
n, d = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
m = set(a)
if n == 1:
    print(d)
else:
    for i in range(len(a)):
        if (a[i] - d) in m:
            k += 1
    print(k)
 