Problem: You are a programmer working for your local city hall. The town you live in has a thriving tourism industry, especially the beaches on the shores of remote islands. The area around this island is composed of sandy beaches, but in recent years the area of ​​the sandy beaches has decreased due to coastal erosion. The Tourism Division, which took the situation seriously, asked you to simulate the shape change of the beach.

In the simulation, the shape of the beach after a certain period of time is obtained based on the current shape of the beach. For simplicity, the shape of the island's coastline is considered polygonal (not necessarily convex). During the period, it is assumed that the beach is eroded by R at a distance from the current coastline in Manhattan and sinks into the sea. Here, the Manhattan distance is the sum of the difference between the x-coordinates and the difference between the y-coordinates. That is, the Manhattan distance between (x1, y1) and (x2, y2) is given by | x1 --x2 | + | y1 --y2 |.

Your job is to write a program to find the length of the shoreline obtained as a result of the simulation from the shoreline of the sandy beach given as input. If an island is divided into two or more due to coastal erosion, find the length of the coastline for each divided island and output the sum of them.

It should be noted that the two line segments included in the coastline are parallel and the Manhattan distance is not exactly 2R.

Input

The input consists of multiple datasets. Each dataset is given in the following format.

> N R
> x1 y1
> x2 y2
> ...
> xN yN

The first line gives two non-negative integers N (3 ≤ N ≤ 100) and R (0 <R ≤ 100). These integers represent the number of vertices on the coastline and the distance eroded, respectively. In the following N lines, vertex information is given to each line, one for each line. Vertex information is given by two integers xi, yi (-10000 ≤ xi, yi ≤ 10000). The coordinates (xi, yi) represent the coordinates of the i-th vertex of the coastline, respectively. The coordinates of the vertices of the island are always given counterclockwise.

The end of the input is indicated by a single line containing two zeros separated by blanks.

Output

Output the length of the eroded coastline for each dataset. If the island is completely eroded and disappears, the length of the coastline should be treated as 0.0. The output value may contain an error of 0.01 or less. In addition, the value may be displayed in any number of digits after the decimal point.

Sample Input


3 1
0 0
10 0
5 10
3 1
0 0
10 0
0 10
4 1
0 0
10 0
10 10
0 10
0 0


Output for the Sample Input


22.6524758425
23.8994949366
32.0000000000






Example

Input

3 1
0 0
10 0
5 10
3 1
0 0
10 0
0 10
4 1
0 0
10 0
10 10
0 10
0 0


Output

22.6524758425
23.8994949366
32.0000000000

Solution (in CPP):

Solution:
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return (a.X!=b.X) ? a.X<b.X : a.Y<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}

bool intersectLS(const L& l, const L& s){
    return cross(l[1]-l[0], s[0]-l[0])*
        cross(l[1]-l[0], s[1]-l[0]) < EPS;
}
bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}
P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}

double L1distance(const P &a, const P &b){
    return abs(b.X -a.X) +abs(b.Y -a.Y);
}
double L1distanceSP(const L &s, const P &p){
    double ret = INF;
    for(int i=0; i<2; i++){
        L gl(p, p +P(i, 1-i));
        if(!isParallel(s, gl) && intersectLS(gl, s)){
            P cp = crosspointLL(s, L(p, p+P(i,1-i)));
            ret = min(ret, abs(p -cp));
        }
        ret = min(ret, L1distance(p, s[i]));
    }
    return ret;
}

int in_poly(const P &p, const VP &poly){
    int n = poly.size();
    int ret = -1;
    for(int i=0; i<n; i++){
        P a = poly[i]-p;
        P b = poly[(i+1)%n]-p;
        if(a.Y > b.Y) swap(a,b);
        if(intersectSP(L(a,b), P(0,0))) return 0;
        if(a.Y<=0 && b.Y>0 && cross(a,b)<0) ret = 1-ret;
    }
    return ret;
}
vector<L> arrangement(const vector<L> &e){
    vector<VP> cp(e.size());
    for(int i=0; i<(int)e.size(); i++){
        for(int j=i+1; j<(int)e.size(); j++){
            if(!isParallel(e[i], e[j]) && intersectSS(e[i], e[j])){
                P cpij = crosspointLL(e[i], e[j]);
                cp[i].push_back(cpij);
                cp[j].push_back(cpij);
            }
        }
        sort(cp[i].begin(), cp[i].end());
        cp[i].erase(unique(cp[i].begin(), cp[i].end()), cp[i].end());
    }

    vector<L> ret;
    for(int i=0; i<(int)e.size(); i++){
        for(int j=0; j<(int)cp[i].size()-1; j++){
            ret.push_back(L(cp[i][j], cp[i][j+1]));
        }
    }
    sort(ret.begin(), ret.end());
    ret.erase(unique(ret.begin(), ret.end()), ret.end());
    return ret;
}


int main(){
    while(1){
        int n,r;
        cin >> n >> r;
        if(n==0) break;
        
        VP v(n);
        for(int i=0; i<n; i++){
            double x,y;
            cin >> x >> y;
            v[i] = P(x,y);
        }
        vector<VP> sq(n, VP(4));
        for(int i=0; i<n; i++){
            sq[i][0] = v[i] +P(r, 0);
            sq[i][1] = v[i] +P(0, r);
            sq[i][2] = v[i] +P(-r, 0);
            sq[i][3] = v[i] +P(0, -r);
        }

        vector<L> l;
        l.reserve(9*n);
        for(int i=0; i<n; i++){
            l.push_back(L(v[i], v[(i+1)%n]));
            for(int j=0; j<4; j++){
                l.push_back(L(sq[i][j], sq[(i+1)%n][j]));
                l.push_back(L(sq[i][j], sq[i][(j+1)%4]));
            }
        }
        vector<L> cand = arrangement(l);

        double ans = 0;
        for(int i=0; i<(int)cand.size(); i++){
            bool rem = true;
            for(int j=0; j<n; j++){
                P mid = (cand[i][0] +cand[i][1])/2.0;
                if(L1distanceSP(L(v[j], v[(j+1)%n]), mid) +EPS < r || in_poly(mid, v) == -1){
                    rem = false;
                    break;
                }
            }
            if(rem){
                ans += abs(cand[i][1] -cand[i][0]);
            }
        }
        cout << fixed;
        cout << setprecision(10);
        cout << ans << endl;
    }
    return 0;
}