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 JAVA):

Solution:
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Shore Erosion
// 2013/05/12
public class Main{
	Scanner sc=new Scanner(System.in);

	double EPS=1e-6;

	int n;
	double r;
	P[] ps;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			r=sc.nextInt();
			ps=new P[n];
			for(int i=0; i<n; i++){
				ps[i]=new P(sc.nextInt(), sc.nextInt());
			}
			solve();
		}
	}

	void solve(){
		P[][] qs=new P[n][];
		for(int i=0; i<n; i++){
			qs[i]=new P[]{ps[i].add(new P(0, r)), ps[i].add(new P(r, 0)),
					ps[i].add(new P(0, -r)), ps[i].add(new P(-r, 0))};
		}

		ArrayList<Seg> list1=new ArrayList<Seg>();

		for(int i=0; i<n; i++){
			int j=(i+1)%n;
			for(int k=0; k<4; k++){
				list1.add(new Seg(qs[i][k], qs[i][(k+1)%4]));
				list1.add(new Seg(qs[i][k], qs[j][k]));
			}
		}

		ArrayList<P> clist=new ArrayList<P>();
		for(Seg segP : list1){
			P p1=segP.p1, p2=segP.p2;
			for(Seg segQ : list1){
				P q1=segQ.p1, q2=segQ.p2;
				if(crsSS(p1, p2, q1, q2)){
					P c=isLL(p1, p2, q1, q2);
					if(c!=null){
						clist.add(c);
					}
				}
			}
			clist.add(p1);
			clist.add(p2);
		}

		ArrayList<Seg> list2=new ArrayList<Seg>();
		for(Seg segP : list1){
			P p1=segP.p1, p2=segP.p2;
			ArrayList<P> list=new ArrayList<P>();
			for(P q : clist){
				if(disSP(p1, p2, q)<EPS){
					list.add(q);
				}
			}
			P[] cs=list.toArray(new P[0]);
			int m=cs.length;
			for(int i=0; i<m; i++){
				for(int j=i+1; j<m; j++){
					double d1=cs[i].sub(p1).abs();
					double d2=cs[j].sub(p1).abs();
					if(d1>d2){
						P t=cs[i];
						cs[i]=cs[j];
						cs[j]=t;
					}
				}
			}
			for(int i=0; i<m-1; i++){
				if(cs[i].sub(cs[i+1]).abs()>EPS){
					list2.add(new Seg(cs[i], cs[i+1]));
				}
			}
		}
		Seg[] segs=list2.toArray(new Seg[0]);
		int m=segs.length;
		boolean[] use=new boolean[m];
		fill(use, true);
		double sum=0;
		for(int i=0; i<m; i++){
			if(!use[i]){
				continue;
			}
			P p1=segs[i].p1, p2=segs[i].p2;
			for(int j=i+1; j<m; j++){
				P q1=segs[j].p1, q2=segs[j].p2;
				if(p1.sub(q1).abs()<EPS&&p2.sub(q2).abs()<EPS
						||p1.sub(q2).abs()<EPS&&p2.sub(q1).abs()<EPS){
					use[j]=false;
				}
			}
			P mid=p1.add(p2).div(2);
			double d=Double.MAX_VALUE;
			P x1=new P(-1e6, mid.y), x2=new P(+1e6, mid.y);
			P y1=new P(mid.x, -1e6), y2=new P(mid.x, +1e6);
			for(int k=0; k<n; k++){
				P q1=ps[k], q2=ps[(k+1)%n];
				d=min(d, abs(q1.x-mid.x)+abs(q1.y-mid.y));
				if(crsSS(x1, x2, q1, q2)){
					P c=isLL(x1, x2, q1, q2);
					if(c!=null){
						d=min(d, c.sub(mid).abs());
					}
				}
				if(crsSS(y1, y2, q1, q2)){
					P c=isLL(y1, y2, q1, q2);
					if(c!=null){
						d=min(d, c.sub(mid).abs());
					}
				}
			}
			if(d+EPS>r){
				if(contains(ps, p1)==1){
					sum+=p1.sub(p2).abs();
				}
			}
		}
		println(String.format("%.12f", sum));
	}

	double disSP(P p1, P p2, P q){
		if(p2.sub(p1).dot(q.sub(p1))<EPS)
			return q.sub(p1).abs();
		if(p1.sub(p2).dot(q.sub(p2))<EPS)
			return q.sub(p2).abs();
		return disLP(p1, p2, q);
	}

	double disLP(P p1, P p2, P q){
		return abs(p2.sub(p1).det(q.sub(p1)))/p2.sub(p1).abs();
	}

	boolean crsSS(P p1, P p2, P q1, P q2){
		if(max(p1.x, p2.x)+EPS<min(q1.x, q2.x))
			return false;
		if(max(q1.x, q2.x)+EPS<min(p1.x, p2.x))
			return false;
		if(max(p1.y, p2.y)+EPS<min(q1.y, q2.y))
			return false;
		if(max(q1.y, q2.y)+EPS<min(p1.y, p2.y))
			return false;
		return signum(p2.sub(p1).det(q1.sub(p1)))
				*signum(p2.sub(p1).det(q2.sub(p1)))<EPS
				&&signum(q2.sub(q1).det(p1.sub(q1)))
						*signum(q2.sub(q1).det(p2.sub(q1)))<EPS;
	}

	P isLL(P p1, P p2, P q1, P q2){
		double d=q2.sub(q1).det(p2.sub(p1));
		if(abs(d)<EPS)
			return null;
		return p1.add(p2.sub(p1).mul(q2.sub(q1).det(q1.sub(p1))/d));
	}

	int contains(P[] ps, P q){
		int n=ps.length;
		int res=-1;
		for(int i=0; i<n; i++){
			P a=ps[i].sub(q), b=ps[(i+1)%n].sub(q);
			if(a.y>b.y){
				P t=a;
				a=b;
				b=t;
			}
			if(a.y<EPS&&b.y>EPS&&a.det(b)>EPS){
				res=-res;
			}
			if(abs(a.det(b))<EPS&&a.dot(b)<EPS)
				return 0;
		}
		return res;
	}

	class Seg{
		P p1, p2;

		Seg(P p1, P p2){
			this.p1=p1;
			this.p2=p2;
		}
	}

	class P implements Comparable<P>{
		double x, y;

		P(double x, double y){
			this.x=x;
			this.y=y;
		}

		P add(P p){
			return new P(x+p.x, y+p.y);
		}

		P sub(P p){
			return new P(x-p.x, y-p.y);
		}

		P mul(double m){
			return new P(x*m, y*m);
		}

		P div(double d){
			return new P(x/d, y/d);
		}

		double abs(){
			return sqrt(abs2());
		}

		double abs2(){
			return x*x+y*y;
		}

		double arg(){
			return atan2(y, x);
		}

		double dot(P p){
			return x*p.x+y*p.y;
		}

		double det(P p){
			return x*p.y-y*p.x;
		}

		double ang(P p){
			return atan2(det(p), dot(p));
		}

		P rot90(){
			return new P(y, -x);
		}

		P rot(double d){
			return new P(cos(d)*x-sin(d)*y, sin(d)*x+cos(d)*y);
		}

		public int compareTo(P p){
			return Double.compare(x, p.x)*2+Double.compare(y, p.y);
		}

		public String toString(){
			return String.format("(%.3f, %.3f)", x, y);
		}
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}