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

#define MW (1000)

#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

short N, R, rw=1024, cirWidth[1001], cir[1000][2];
short tmp=0;

void paint(short i, short j, vector<bool> &row)
{
  static short l, r;
  static char fll, flr;
  tmp+=j-i;
  fll=flr=1;
  l=rw+i;
  r=rw+j;
  if(l==r)
  {
    row[l]=!row[l];
    return;
  }
  while((l>>1)!=(r>>1))
  {
    if((l&1)&&fll)
    {
      row[l]=!row[l];
      fll=0;
    }
    if(!(r&1)&&flr)
    {
      row[r]=!row[r];
      flr=0;
    }
    if((r&1)&& !flr)
      row[r-1]=!row[r-1];
    if(!(l&1) && !fll)
      row[l+1]=!row[l+1];
    l>>=1;
    r>>=1;
  }

  if(fll&&flr)
    row[r>>1]=!row[r>>1];
  else
    if(fll)
      row[l]=!row[l];
    else
      if(flr)
        row[r]=!row[r];
}

long count(vector<bool> &row)
{
  static short i;
  static long res;
  res=0;
  for(i=1; i<rw; ++i)
  {
    row[i<<1]=row[i<<1]^row[i];
    row[(i<<1)+1]=row[(i<<1)+1]^row[i];
  }
  for(i=rw; i<2*rw; ++i)
    if(row[i])
      ++res;
  return res;
}

void input(void)
{
  short i;
  scanf("%hd %hd", &N, &R);
  for(i=0; i<N; ++i)
  {
    scanf("%hd %hd", &cir[i][0], &cir[i][1]);
    cir[i][0]+=512;
    cir[i][1]+=512;
  }
}

int main(void)
{
  short i, j;
  long res;
  input();
  vector<bool> row(rw*2, false);
  vector<vector<bool> > iTree(MW, row);
  for(i=1; i<=R; ++i)
    cirWidth[i]=(short)ceil(sqrt(2*i*R-i*i));
  for(i=0; i<N; ++i)
  {
    for(j=1; j<R; ++j)
    {
      paint(cir[i][0]-cirWidth[j], cir[i][0]+cirWidth[j]-1, iTree[cir[i][1]-R+j]);
      paint(cir[i][0]-cirWidth[j], cir[i][0]+cirWidth[j]-1, iTree[cir[i][1]+R-j+1]);
    }
    paint(cir[i][0]-cirWidth[R], cir[i][0]+cirWidth[R]-1, iTree[cir[i][1]]);
    paint(cir[i][0]-cirWidth[R], cir[i][0]+cirWidth[R]-1, iTree[cir[i][1]+1]);
  }
  for(i=res=0; i<iTree.size(); ++i)
    res+=count(iTree[i]);
  printf("%ld\n", res);
  /*paint(10, 20, iTree[0]);
  paint(15, 25, iTree[0]);
  printf("%ld\n", count(iTree[0]));*/
  return 0;
}

