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

#include <cstdio>
#include <utility>
#include <vector>
#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);
	int i, j;
	for (i = 0; i < N; ++i)
		scanf ("%hu %hu", coor[i], coor[i] + 1);

	//
	#warning with overflow
	int l, r, m;
	int Rsq = R * R;
	int otsq;//other squared
	for (i = 0; i < R; ++i) {//above (below)
		l = 0, r = R;
		otsq = (R - i - 1) * (R - i - 1);
		while (l + 1 < r) {
			m = (l + r) / 2;
			if (m * m + otsq >= Rsq)
				r = m;
			else
				l = m;
		}
		for (j = 0; j < N; ++j) {
			vec[BASE + coor[j][1] - (R - i)    ].push_back (BASE + coor[j][0] - r);
			vec[BASE + coor[j][1] - (R - i)    ].push_back ((BASE + coor[j][0] + r) | END);
			vec[BASE + coor[j][1] + (R - i - 1)].push_back (BASE + coor[j][0] - r);
			vec[BASE + coor[j][1] + (R - i - 1)].push_back ((BASE + 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));
	}*/

	int res = 0;
	unsigned short prev, opened;
	for (i = 0; i < MAXCOOR; ++i) {
		if (vec[i].size () == 0) continue;
		std::sort (vec[i].begin (), vec[i].end (), cmp);
/*		printf ("line %d:", i);
		for (j = 0; j < (int)vec[i].size (); ++j)
			printf ("(%hd %d)", (short)(vec[i][j] & NEND) - BASE, !!(vec[i][j] & END));
		printf ("\n");*/
		prev = opened = 0;
		for (j = 0; j < vec[i].size (); ++j) {
			res += ((vec[i][j] & NEND) - prev) * (opened & 1);
			prev = vec[i][j] & NEND;
			opened += ((!(vec[i][j] & END)) * 2) - 1;
		}
//		assert (opened == 0);
	}

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

	return 0;
}
