/*
TASK:colxor
LANG:C++
*/

#include <cstdio>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cassert>

#warning check R = 1 --> DONE
#warning check R = 1000 N = 1000 !!!
#warning try when the segments start from the same place --> DONE

const int MAXN = 1 << 10;
#warning try different MAXCOOR
const int MAXCOOR = 1 << 15;
const int BASE = 1 << 14;

const unsigned short END = 1 << 15;
const unsigned short NEND = ~END;

int N, R;
short coor[MAXN][2];
std::vector <unsigned short> vec[MAXCOOR];

inline bool cmp (unsigned short a, unsigned short b) {
	return (a & NEND) < (b & NEND);
}

int main () {
	scanf ("%d %d", &N, &R);
	register int i, j;
	for (i = 0; i < N; ++i) {
		scanf ("%hu %hu", coor[i], coor[i] + 1);
		coor[i][0] += BASE;
		coor[i][1] += BASE;
	}

	//
	#warning with overflow
	int l, r, m;
	int Rsq = R * R;
	int otsq;//other squared
	unsigned short _R_i, _Rpi;
	double _r;
	int _r1, _r2;
	for (i = 0; i < R; ++i) {//above (below)
		_R_i = R-i;
		_Rpi = _R_i-1;

		otsq = _Rpi * _Rpi;
/*		l = 0, r = R;
		while (l + 1 < r) {
			m = (l + r) / 2;
			if (m * m + otsq >= Rsq)
				r = m;
			else
				l = m;
		}*/
		_r = sqrt (Rsq - otsq);
		_r1 = (int)floor (_r);
		_r2 = (int)ceil (_r);
//		assert (_r2 * _r2 + otsq >= Rsq);
		if (_r1 * _r1 + otsq >= Rsq) r = _r1; else r = _r2;
		for (j = 0; j < N; ++j) {
			vec[coor[j][1] - _R_i].push_back (coor[j][0] - r);
			vec[coor[j][1] - _R_i].push_back ((coor[j][0] + r) | END);
			vec[coor[j][1] + _Rpi].push_back (coor[j][0] - r);
			vec[coor[j][1] + _Rpi].push_back ((coor[j][0] + r) | END);
		}
	}

/*	int a, b;
	int i, j;
	while (scanf ("%d %d", &a, &b) == 2) {
		vec[0].push_back (b ? (a + BASE) | END : (a + BASE));
	}*/

	register int res = 0;
	register unsigned short prev, opened, _prev, __sz;
	for (i = 5000; i < MAXCOOR - 5000; ++i) {
		if (vec[i].size () == 0) continue;
		std::sort (vec[i].begin (), vec[i].end (), cmp);
		for (j = prev = opened = 0, __sz = vec[i].size (); j < __sz; ++j) {
			_prev = vec[i][j] & NEND;
			res += (_prev - prev) * (opened & 1);
			prev = _prev;
			opened += ((!(vec[i][j] & END)) << 1) - 1;
		}
//		assert (opened == 0);
	}

	printf ("%d\n", res);

	return 0;
}
