#include<cstdio>
#include<complex>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

typedef complex<double> Point;
typedef complex<double> Vector;

typedef pair<Point,Point> Segment;

const double eps=1e-9;
const double PI=acos(-1.0);

bool check(double,double,double);

template<class T> bool eq(T a,T b){
	return abs(a-b)<eps;
}

int sgn(double a){
	if(eq(a,0.0)) return 0;
	if(a>0) return 1;
	return -1;
}

double crP(Vector a,Vector b){
	return (conj(a)*b).imag();
}

struct Circle{
	Point center;
	double r;
	bool direct;
	vector<double> angles;
	int id;
	double lb,ub;
	Circle(){}
	Circle(Point p,double r):center(p),r(r){}
	void print(){
		printf("(%f,%f)-%f\n",center.real(),center.imag(),r);
		for(int i=0;i<angles.size();i++) printf("%f ",angles[i]*180/PI);
		printf("\n");
	}
	bool isValid(double ang){
		if(ub>lb) return check(lb,ang,ub);
		else{
			if(ub>=ang) return true;
			if(lb<=ang) return true;
			return false;
		}
	}
};

int ccw(Point p1,Point p2,Point p3){
	Vector b=p2-p1;
	Vector c=p3-p1;
	int s=sgn(crP(b,c));
	if(s==1) return 1;//counterclockwise
	else if(s==-1) return -1;//clockwise
	return 0;//on line
}

bool iSS(Segment s1,Segment s2){
	//端点で交わるのはfalse
	int i1=ccw(s1.first,s1.second,s2.first)*ccw(s1.first,s1.second,s2.second);
	int i2=ccw(s2.first,s2.second,s1.first)*ccw(s2.first,s2.second,s1.second);
	return i1==-1&&i2==-1;
}

double x1,x2,y1_,y2;
double len;
Point points[4];

bool inRect(Point p){
	return sgn(p.real()-x1)==1&&sgn(p.real()-x2)==-1&&
		sgn(p.imag()-y1_)==1&&sgn(p.imag()-y2)==-1;
}

void print(Point p){
	printf("(%f,%f) ",p.real(),p.imag());
}

bool inRect(Point p,Point q){
//	print(p);print(q);printf("\n");
	//q::(0,0) or one of the vertices
	Segment seg=Segment(p,q);
	for(int i=0;i<4;i++){
		Point p1=points[i],p2=points[(i+1)%4];
		bool flg=iSS(Segment(p1,p2),seg);
		if(flg==true) return true;
	}
	
//	Point tmp=(p-q)/abs(p-q)+q;
//	if(inRect(tmp)) return true;
	if(inRect(p)) return true;
	if(inRect(q)) return true;
	if(inRect((p+q)/2.0)) return true;
	return false;
}

inline double normalize(double a){
	while(a<0) a+=(PI*2);
	while(a>PI*2) a-=(PI*2);
	return a;
}

void addICC(Circle &c1,Circle &c2){
	double d=abs(c1.center-c2.center);
	int s=sgn(c1.r+c2.r-d);
	double r1=c1.r,r2=c2.r;
	if(s==0){
		//接するときの処理
		
		return ;
	}
	if(s==-1) return ;
	double sm=min(r1,r2),la=max(r1,r2);
	if(sgn(d+sm-la)<=0) return;
	Vector vec1=c2.center-c1.center;
	double theta1=acos((r1*r1+d*d-r2*r2)/(2.0*r1*d));
	double ang1=atan2(vec1.imag(),vec1.real());
	c1.angles.push_back(normalize(ang1-theta1));
	c1.angles.push_back(normalize(ang1+theta1));
	
	Vector vec2=c1.center-c2.center;
	double theta2=acos((r2*r2+d*d-r1*r1)/(2.0*r2*d));
	double ang2=atan2(vec2.imag(),vec2.real());
	c2.angles.push_back(normalize(ang2-theta2));
	c2.angles.push_back(normalize(ang2+theta2));
}

bool check(double a,double b,double c){
	if(a<c) return a<=b+eps&&b<=c+eps;
//	printf("check %f %f %f\n",a,b,c);
	return true;
}

bool isin(Circle c,Point p){
	if(sgn(c.r-abs(c.center-p))<=0) return false;
	double ang=atan2((p-c.center).imag(),(p-c.center).real());
	if(c.isValid(ang)) return true;
	return false;
}

vector<Circle> circles;
double lb,ub;

Circle c;

double rs[4];

void put1(){
	circles.clear();
	lb=atan2(points[1].imag(),points[1].real());
	ub=atan2(points[3].imag(),points[3].real());
	for(int i=0;i<4;i++) rs[i]=0;
	rs[1]=max(rs[1],len-abs(points[1]));
	rs[2]=max(rs[2],rs[1]-abs(points[2]-points[1]));
	rs[3]=max(rs[3],len-abs(points[3]));
	rs[2]=max(rs[2],rs[3]-abs(points[2]-points[3]));
	for(int i=1;i<4;i++){
		if(rs[i]<eps) continue;
		Circle tmp=Circle(points[i],rs[i]);
		for(int j=0;j<4;j++){
			tmp.angles.push_back(PI/2*j);
		}
		if(i==1){
			tmp.angles.push_back(lb);
			tmp.angles.push_back(lb+PI);
		}
		if(i==3){
			tmp.angles.push_back(ub);
			tmp.angles.push_back(ub+PI);
		}
		if(i==1){
			tmp.lb=lb;
			tmp.ub=PI/2;
		}else if(i==2){
			tmp.lb=PI*3/2;
			tmp.ub=PI;
		}else if(i==3){
			tmp.lb=0;
			tmp.ub=ub;
		}
		circles.push_back(tmp);
	}
	c=Circle(Point(0,0),len);
	c.lb=ub,c.ub=lb;
}

void put2(){
	circles.clear();
	lb=atan2(points[1].imag(),points[1].real());
	ub=atan2(points[0].imag(),points[0].real());
	for(int i=0;i<4;i++) rs[i]=0;
	double total=abs(points[1]);
	rs[1]=max(rs[1],len-total);
	for(int i=2;i<=3;i++){
		total+=abs(points[i]-points[i-1]);
		rs[i]=max(rs[i],len-total);
	}
	total=abs(points[0]);
	rs[0]=max(rs[0],len-total);
	for(int i=3;i>=2;i--){
		total+=abs(points[i]-points[(i+1)%4]);
		rs[i]=max(rs[i],len-total);
	}
	for(int i=0;i<4;i++){
		if(rs[i]<eps) continue;
		Circle tmp=Circle(points[i],rs[i]);
		for(int j=0;j<4;j++){
			tmp.angles.push_back(PI/2*j);
		}
		if(i==1){
			tmp.angles.push_back(lb);
			tmp.angles.push_back(lb+PI);
		}
		if(i==0){
			tmp.angles.push_back(ub);
			tmp.angles.push_back(ub+PI);
		}
		if(i==0){
			tmp.lb=PI/2;
			tmp.ub=ub;
		}else if(i==1){
			tmp.lb=lb;
			tmp.ub=PI/2;
		}else if(i==2){
			tmp.lb=PI*3/2;
			tmp.ub=PI;
		}else{
			tmp.lb=0;
			tmp.ub=PI*3/2;
		}
		circles.push_back(tmp);
	}
	c=Circle(Point(0,0),len);
	c.lb=ub,c.ub=lb;
}

double solve(){
	for(int i=0;i<circles.size();i++) for(int j=0;j<i;j++){
		addICC(circles[i],circles[j]);
	}
	double res=0;
	for(int i=0;i<circles.size();i++){
		vector<double> vec=circles[i].angles;
		sort(vec.begin(),vec.end());
	//	printf("(%f,%f),%f,%f-%f\n",circles[i].center.real(),circles[i].center.imag(),circles[i].r
	//		,circles[i].lb,circles[i].ub);
		for(int j=0;j<vec.size();j++){
			double ang1=vec[j];
			double ang2=j+1==vec.size()?vec[0]+PI*2:vec[j+1];
		//	printf("%f %f %f\n",ang1,ang2,circles[i].r);
			double mid=normalize((ang1+ang2)/2);
			Point cur=circles[i].center+Point(cos(mid),sin(mid))*circles[i].r;
			if(circles[i].isValid(mid)==false) continue;
			bool in=false;
			for(int k=0;k<circles.size();k++) if(isin(circles[k],cur)) in=true;
			if(in) continue;
			if(isin(c,cur)) continue;
			res+=(ang2-ang1)*circles[i].r;
		//	printf("passed\n");
		}
	}
	//printf("%f\n",res);
	vector<double> angles;
	angles.push_back(lb);
	angles.push_back(ub);
	double vals[]={x1,y1_};
	for(int i=0;i<2;i++){
		double v=vals[i];
		v=abs(v);
		if(sgn(v-len)>=0) continue;
		double ang=acos(v/len);
	//	printf("ang=%f\n",ang);
		for(int j=0;j<2;j++){
			angles.push_back(ang+PI/2*j);
			angles.push_back(PI/2*(j+1)-ang);
		}
	}
	sort(angles.begin(),angles.end());
	for(int i=0;i<angles.size();i++){
		double ang1=angles[i];
		double ang2=i+1==angles.size()?angles[0]+PI*2:angles[i+1];
		double mid=(ang1+ang2)/2;
		Point p=Point(cos(mid),sin(mid))*len;
		if(inRect(Point(0,0),p)) continue;
		res+=(ang2-ang1)*len;
	//	printf("%f %f\n",ang1,ang2);
	}
	return res;
}
int main(){
	while(true){
		scanf("%lf%lf%lf%lf%lf",&len,&x1,&y1_,&x2,&y2);
		if(eq(len,0.0)) break;
		if(x2<=0){
			x1*=-1;
			x2*=-1;
		}
		if(y2<=0){
			y1_*=-1;
			y2*=-1;
		}
		if(x1>x2) swap(x1,x2);
		if(y1_>y2) swap(y1_,y2);
		if(y1_<0){
			swap(x1,y1_);
			swap(x2,y2);
		}
		circles.clear();
		points[0]=Point(x1,y1_);
		points[1]=Point(x2,y1_);
		points[2]=Point(x2,y2);
		points[3]=Point(x1,y2);
		if(x1>=0) put1();
		else put2();
		double ans=solve();
	//	printf("r::");
	//	for(int i=0;i<4;i++) printf("%f \n",rs[i]);
	//	printf("\n");
	//	printf("(%.0f,%.0f,%.0f,%.0f,%.0f)->",len,x1,y1_,x2,y2);
		printf("%.9f\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1244