#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
const int MAXN = 1000000;
int a[MAXN];
int main() {
    //freopen("E:/in.txt", "r", stdin);
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    map<pair<int, int>, int> m;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int t = a[j] - a[i];
            if (t == k)
                m[pair<int, int>(a[i], a[j])] = 0;
            else if (t > k)
                break;
        }
    }
    printf("%d", m.size());
    return 0;
}