#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#pragma GCC optimize(2)
#endif
#define OFF_SYNC ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cerr.tie(0), clog.tie(0);
#define endl "\n"
using _us = unsigned;
using _s = signed;
using _sll = signed long long;
using _ull = unsigned long long;
using _d = double;
using _ld = long double;
const _sll N = 1010;
const _sll M = 10010;
const _sll L = 100010;
const _sll INF = 0x3f3f3f3f;
_sll n, c, g, ans;
vector<_sll> v;
int main() {
OFF_SYNC
cin >> n >> c;
for (_sll i=0; i<n; i++) {
cin >> g;
v.push_back(g);
}
sort(v.begin(), v.end());
for (auto i: v) {
ans += count_if(v.begin(), v.end(), [&](_sll a)->bool{
return a>i && a-i==c;
});
}
cout << ans;
return 0;
}