#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int contar_pares(int diff, set<int> numeros){
int cont = 0;
for (auto num: numeros){
if (numeros.find(num - diff) != numeros.end()){
cont++;
}
if (numeros.find(num + diff) != numeros.end()){
cont++;
}
}
return cont / 2;
}
int main(){
int n, k;
cin >> n >> k;
int tamanho = n;
set<int> numeros;
for(int i = 0; i < tamanho; i++){
int num;
cin >> num;
numeros.insert(num);
}
cout << contar_pares(k, numeros) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c2V0Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGNvbnRhcl9wYXJlcyhpbnQgZGlmZiwgc2V0PGludD4gbnVtZXJvcyl7CiAgICBpbnQgY29udCA9IDA7CiAgICBmb3IgKGF1dG8gbnVtOiBudW1lcm9zKXsKICAgICAgICBpZiAobnVtZXJvcy5maW5kKG51bSAtIGRpZmYpICE9IG51bWVyb3MuZW5kKCkpewogICAgICAgICAgICBjb250Kys7CiAgICAgICAgfQogICAgICAgIGlmIChudW1lcm9zLmZpbmQobnVtICsgZGlmZikgIT0gbnVtZXJvcy5lbmQoKSl7CiAgICAgICAgICAgIGNvbnQrKzsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gY29udCAvIDI7Cn0KCmludCBtYWluKCl7CiAgICBpbnQgbiwgazsKICAgIGNpbiA+PiBuID4+IGs7CiAgICBpbnQgdGFtYW5obyA9IG47CiAgICBzZXQ8aW50PiBudW1lcm9zOwogICAgZm9yKGludCBpID0gMDsgaSA8IHRhbWFuaG87IGkrKyl7CiAgICAgICAgaW50IG51bTsKICAgICAgICBjaW4gPj4gbnVtOwogICAgICAgIG51bWVyb3MuaW5zZXJ0KG51bSk7CiAgICB9CiAgICBjb3V0IDw8IGNvbnRhcl9wYXJlcyhrLCBudW1lcm9zKSA8PCBlbmRsOwoKICAgIHJldHVybiAwOwp9Cg==