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 <cstdio>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <set>
using namespace std;

typedef double D;
typedef complex<D> P;
typedef const P &rP;
typedef pair<P,P> seg;

const D EPS = 1e-7;
const D INF = 1e99;

D pi;

namespace std{
	bool operator< (rP a, rP b){
		if(abs(real(a) - real(b)) > EPS){
			return real(a) < real(b);
		}
		return imag(a) < imag(b) - EPS;
	}
}

D dot(rP a, rP b){
	return real(a) * real(b) + imag(a) * imag(b);
}

D cross(rP a, rP b){
	return real(a) * imag(b) - imag(a) * real(b);
}

int ccw(rP a, P b, P c){
	b -= a;
	c -= a;
	D cr = cross(b, c);
	if(abs(cr) > EPS){
		return cr > 0 ? 1 : -1;
	}
	if(dot(b, c) < -EPS){
		return 2;
	}
	if(abs(b) < abs(c) - EPS){
		return -2;
	}
	return 0;
}

int ccw(const seg &s, rP c){
	return ccw(s.first, s.second, c);
}

D distSP2(rP a, rP b, rP c){
	if(dot(b - a, c - a) <= 0.0){ return abs(c - a); }
	if(dot(a - b, c - b) <= 0.0){ return abs(c - b); }
	return abs(cross(b - a, c - a)) / abs(b - a);
}

P intrSS(const seg &a, const seg &b){
	rP pa1 = a.first, pa2 = a.second, pb1 = b.first, pb2 = b.second;
	P da12 = pa2 - pa1;
	P db21 = pb1 - pb2;
	P dab1 = pb1 - pa1;
	D d = cross(da12, db21);
	if(abs(d) > EPS){
		D t = cross(dab1, db21) / d;
		D s = cross(da12, dab1) / d;
		if(-EPS < t && t < 1.0 + EPS && -EPS < s && s < 1.0 + EPS){
			return pa1 + t * da12;
		}
	}
	return P(INF, INF);
}

bool contains(const vector<P> &plg, rP pt){
	int cnt = 0;
	D y = imag(pt);
	for(size_t i = 1; i < plg.size(); ++i){
		if(distSP2(plg[i - 1], plg[i], pt) < EPS){
			return false;
		}
		D dyi = imag(plg[i]) - y;
		D dyj = y - imag(plg[i - 1]);
		D tx = (dyi * real(plg[i - 1]) + dyj * real(plg[i])) / (dyi + dyj);
		if(imag(plg[i]) >= y && imag(plg[i - 1]) < y){
			if(tx < real(pt)){ ++cnt; }
		}
		else if(imag(plg[i]) < y && imag(plg[i - 1]) >= y){
			if(tx < real(pt)){ ++cnt; }
		}
	}
	return (cnt % 2 != 0);
}


bool merge_if_able(seg &s, seg &t){
	if(abs(cross(s.second - s.first, t.second - t.first)) > EPS){
		return false;
	}
	if(abs(ccw(s.first, t.first, s.second)) == 1){
		return false;
	}
	if(ccw(s, t.first) == -2 || ccw(t, s.first) == -2){
		return false;
	}
	s = seg(min(s.first, t.first), max(s.second, t.second));
	return true;
}
void mergeseg(vector<seg> &segs){
	for(size_t i = 0; i < segs.size(); ++i){
		if(segs[i].second < segs[i].first){
			swap(segs[i].first, segs[i].second);
		}
	}
	
	int inc = 1;
	for(size_t i = 0; i < segs.size(); i += inc){
		inc = 1;
		for(size_t j = i + 1; j < segs.size(); ++j){
			if(merge_if_able(segs[i], segs[j])){
				segs[j--] = segs.back();
				segs.pop_back();
				inc = 0;
			}
		}
	}
}

void segarrange(vector<seg> &ss){
	set<P> s_ps;
	for(size_t i = 0; i < ss.size(); ++i){
		s_ps.insert(ss[i].first);
		s_ps.insert(ss[i].second);
		for(size_t j = i + 1; j < ss.size(); ++j){
			P t = intrSS(ss[i], ss[j]);
			if(real(t) != INF){
				s_ps.insert(t);
			}
		}
	}

	vector<P> ps(s_ps.begin(), s_ps.end());
	vector<seg> res;
	for(size_t i = 0; i < ss.size(); ++i){
		vector<pair<D,int> > ls;
		for(size_t j = 0; j < ps.size(); ++j){
			if(ccw(ss[i], ps[j]) == 0){
				ls.push_back(make_pair(abs(ss[i].first - ps[j]), j));
			}
		}
		sort(ls.begin(), ls.end());
		for(size_t j = 0; j + 1 < ls.size(); ++j){
			int a = ls[j].second, b = ls[j + 1].second;
			res.push_back(seg(ps[a], ps[b]));
		}
	}

	ss.swap(res);
}

int segtype1(const seg &s){
	D a = arg(s.second - s.first);
	return min(abs(a - 0.5 * pi), abs(a + 0.5 * pi)) < 0.25 * pi ? 1 : 0;
}

D distPP1(rP a, rP b){
	return abs(real(a) - real(b)) + abs(imag(a) - imag(b));
}

D distSP1(const seg &s, rP p){
	D a[2] = {real(s.first), imag(s.first)};
	D b[2] = {real(s.second), imag(s.second)};
	D c[2] = {real(p), imag(p)};
	int t = segtype1(s);
	if(a[t] > b[t]){
		swap(a[0], b[0]);
		swap(a[1], b[1]);
	}

	if(c[t] < a[t]){
		return distPP1(p, P(a[0], a[1]));
	}
	if(c[t] > b[t]){
		return distPP1(p, P(b[0], b[1]));
	}

	D d = (b[1 - t] - a[1 - t]) / (b[t] - a[t]) * (c[t] - a[t]) + a[1 - t];
	return abs(c[1 - t] - d);
}

int main(){
	pi = acos(-1.0);
	cout << fixed << setprecision(9);

	int n;
	D r, x, y;
	while(cin >> n >> r, n){
		vector<P> plg(n + 1);
		for(int i = 0; i < n; ++i){
			cin >> x >> y;
			plg[i] = P(x, y);
		}
		plg[n] = plg[0];

		P ir(0.0, r);

		vector<seg> segs;
		for(int i = 0; i < n; ++i){
			segs.push_back(seg(plg[i] + r, plg[i] + ir));
			segs.push_back(seg(plg[i] + ir, plg[i] - r));
			segs.push_back(seg(plg[i] - r, plg[i] - ir));
			segs.push_back(seg(plg[i] - ir, plg[i] + r));

			int t = segtype1(seg(plg[i], plg[i + 1]));
			if(t == 0){
				segs.push_back(seg(plg[i] + ir, plg[i + 1] + ir));
				segs.push_back(seg(plg[i] - ir, plg[i + 1] - ir));
			}
			else{
				segs.push_back(seg(plg[i] + r, plg[i + 1] + r));
				segs.push_back(seg(plg[i] - r, plg[i + 1] - r));
			}
		}

		mergeseg(segs);
		segarrange(segs);

		D ans = 0.0;
		for(size_t i = 0; i < segs.size(); ++i){
			P mdp = 0.5 * (segs[i].first + segs[i].second);
			if(contains(plg, mdp)){
				D mindist = INF;
				for(int j = 0; j < n; ++j){
					mindist = min(mindist, distSP1(seg(plg[j], plg[j + 1]), mdp));
				}
				if(abs(mindist - r) < EPS){
					ans += abs(segs[i].second - segs[i].first);
				}
			}
		}
		
		cout << ans << '\n';
	}
}