#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <cstring>
 
 
using namespace std;
 
#define ll long long
 
const int maxn = 1 << 20;

int n;
ll d;
int x[maxn], y[maxn];
 
int main() {
	freopen("distances.in", "r", stdin);
	freopen("distances.out", "w", stdout);

	cin >> n >> d;
	for (int i = 0; i < n; i++) {
	 	cin >> x[i] >> y[i];
	}

	long long ans = 0;
	for (int i = 0; i < n; i++) {
	 	for (int j = i + 1; j < n; j++) {
	 	 	ans += 1LL * (x[i] - x[j]) * (x[i] - x[j]) + 1LL * (y[i] - y[j]) * (y[i] - y[j]) == d;
		}
	}
	cout << ans << endl;
	
    return 0;
}                                                                           