#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cfloat>
using namespace std;

typedef long double D;
typedef complex<D> P;

const D EPS = 1e-9;

D dot(P va, P vb){
	return real(va) * real(vb) + imag(va) * imag(vb);
}

D cross(P va, P vb){
	return real(va) * imag(vb) - imag(va) * real(vb);
}

bool check_angle(D ag, D rg[]){
	return rg[0] - EPS < ag && ag < rg[1] + EPS;
}

void intrcscs(P p1, D r1, D rg1[], P p2, D r2, D rg2[], vector<P> &ret){
	D d = abs(p2 - p1);
	D phi = arg(p2 - p1);
	
	D costheta = (d * d + r1 * r1 - r2 * r2) / (2.0 * d * r1);
	if(abs(costheta) > 1.0){
		if(abs(costheta) < 1.0 + EPS){
			costheta /= abs(costheta);
		}
		else{
			return;
		}
	}
	
	D theta = acos(costheta);

	P pt = p1 + polar(r1, phi + theta);
	if(check_angle(arg(pt - p1), rg1) && check_angle(arg(pt - p2), rg2)){
		ret.push_back(pt);
	}
	pt = p1 + polar(r1, phi - theta);
	if(check_angle(arg(pt - p1), rg1) && check_angle(arg(pt - p2), rg2)){
		ret.push_back(pt);
	}
}

void intrlsc(P p1, P p2, P pc, D r, vector<P> &ret){
	P v12 = p2 - p1;
	P v1c = pc - p1;

	D a = norm(v12);
	D b = -dot(v12, v1c);
	D c = norm(v1c) - r * r;

	D d = b * b - a * c;
	if(d < 0.0 && d > -EPS){
		d = 0.0;
	}
	if(d < 0.0){
		if(d > -EPS){
			d = 0.0;
		}
		else{
			return;
		}
	}

	d = sqrt(d);
	D t1 = (-b + d) / a;
	D t2 = (-b - d) / a;
	
	if(-EPS < t1 && t1 < 1.0 + EPS){
		ret.push_back(p1 + v12 * t1);
	}
	if(-EPS < t2 && t2 < 1.0 + EPS){
		ret.push_back(p1 + v12 * t2);
	}
}


struct info{
	D rem, range[2];
	P cen;

	info() : rem(-1.0){
		range[0] = range[1] = 0.0;
	}
	info(D rm, D rl, D rr, P c) : rem(rm), cen(c){
		range[0] = rl;
		range[1] = rr;
	}
};


D pi = acos(-1.0L);


D solve(D len){
	const D inf = 1e100;
	D x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	info ropes[2], nropes[2];
	D add[2];
	vector<P> plg(4);

	plg[0] = P(x1, y1);
	plg[1] = P(x2, y1);
	plg[2] = P(x2, y2);
	plg[3] = P(x1, y2);
	
	P brot = conj(plg[0]) / abs(plg[0]);
	for(int i = 0; i < 4; ++i){
		plg[i] *= brot;
	}

	ropes[0] = info(len, -pi, pi, P());
	ropes[1] = info(len, -pi, pi, P());

	D ans = 0.0;
	while(max(ropes[0].rem, ropes[1].rem) > EPS){
		for(int k = 0; k < 2; ++k){
			info &rp = ropes[k];
			info &nx = nropes[k];
			nx = info();
			add[k] = 0.0;

			if(rp.rem < EPS){ continue; }

			vector<P> cand = plg;
			
			if(ropes[0].rem < len && ropes[1].rem < len){
				intrcscs(
					ropes[0].cen, ropes[0].rem, ropes[0].range,
					ropes[1].cen, ropes[1].rem, ropes[1].range, cand
				);
			}
			for(int i = 0; i < 4; ++i){
				intrlsc(plg[i], plg[(i + 1) & 3], rp.cen, rp.rem, cand);
			}
			for(int i = 0; i < 2; ++i){
				cand.push_back(ropes[i].cen);
			}

			int minidx = -1;
			D minangle = (k ? -inf : inf);
			D maxdist = -inf;

			for(int i = cand.size(); i--; ){
				D ds = abs(cand[i] - rp.cen);
				D ag = arg(cand[i] - rp.cen);
				
				bool update = false;
				if(	ds > EPS && ds < rp.rem + EPS && check_angle(ag, rp.range)){
					if(abs(minangle - ag) < EPS){
						update = maxdist < ds;
					}
					else{
						update = (minangle > ag) ^ k;
					}
				}

				if(update){
					minidx = i;
					minangle = ag;
					maxdist = ds;
				}
			}

			if(minidx == -1){
				return 2.0 * pi * len;
			}

			add[k] = rp.rem * abs(minangle - rp.range[k]);

			if(minidx < 4){
				nx.range[k] = minangle;
				nx.range[!k] = arg(plg[(minidx + (k ? 3 : 1)) & 3] - plg[minidx]);
				nx.rem = rp.rem - maxdist;
				nx.cen = cand[minidx];
			}
			else{
				nx.rem = 0.0;
				nx.range[0] = nx.range[1] = 0.0;
				nx.cen = cand[minidx];
			}
		}

		int updidx = (nropes[0].rem < nropes[1].rem);
		ans += add[updidx];
		ropes[updidx] = nropes[updidx];
	}
	return ans;
}


int main(){
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(8);

	D len;
	while(cin >> len, len != 0.0){
		D ans = solve(len);
		cout << ans << '\n';
	}
}

Measured memory_bytes: 1332