#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';
	}
}

Measured memory_bytes: 1696