/*
TASK: colxor
LANG: C++
*/
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#define INF 20000
#define MAXN 1024
using namespace std;

 typedef
  struct
   {
    int x,y;
   } point;

 int n,r;
 point a[MAXN];
 pair<int,int> g[2*MAXN];
 int x[MAXN];
 int z;
 pair<int,int> h[MAXN];
 int res;
 int dist[MAXN];
 pair<int,int> f[2*MAXN];
 int size;
 
 int cmpX (int p,int q)
  {
   return a[p].x<a[q].x;
  }

 int main ()
  {
   int i,j,k,l,pom,cur,last,have,er;
   scanf("%d%d",&n,&r);
   for (i=1;i<=n;i++)
    scanf("%d%d",&a[i].x,&a[i].y);
   for (i=0;i<=r;i++)
    dist[i]=(r-i)*(r-i);
   for (i=1;i<=r;i++)
    for (j=1;j<=r;j++)
     if (dist[i]+dist[j]<r*r && r*r<=dist[i-1]+dist[j-1])
      {
       g[i].first=j;
       g[i].second=2*r-j+1;
       g[2*r-i+1].first=j;
       g[2*r-i+1].second=2*r-j+1;
       break;
      }
   for (i=1;i<=n;i++)
    x[i]=i;
   sort(&x[1],&x[n+1],cmpX);
   j=1;
   for (i=-INF;i<=INF;i++)
    {
     l=0;
     for (k=1;k<=z;k++)
      if (h[k].first<2*r)
       {
        swap(h[++l],h[k]);
        h[l].first++;
       }
     z=l;                                
     while (j<=n && a[x[j]].x-r==i)
      {
       h[++z].first=1;
       h[z].second=x[j];
       j++;
      }      
     size=0;
     for (k=1;k<=z;k++)
      {
       f[++size].first=(a[h[k].second].y-r+g[h[k].first].first);
       f[size].second=1;
       f[++size].first=(a[h[k].second].y-r+g[h[k].first].second);
       f[size].second=2;
      }
     sort(&f[1],&f[size+1]);
     pom=have=0;
     for (k=1;k<=size;k++)
      {
       cur=k;
       er=0;
       while (cur+er<=size && f[cur+er].first==f[k].first)
        er++;
       cur+=er;
       pom+=er;
       if (er)
        {
         if (have)
          res+=f[k].first-1-last;
         last=f[k].first-1;
        }        
       er=0;
       while (cur+er<=size && f[cur+er].first==f[k].first)
        er++;
       pom-=er;
       cur+=er;
       if (er)
        {
         if (have)
          res+=f[k].first-last;
         last=f[k].first;
        }
       have=pom%2;
       k=cur-1;
      }
    }
   printf("%d\n",res);
   return 0;
  }
