#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

#include <complex>
#include <cmath>
#define EPS 1.0e-10
#define PI 3.1415926535897932384 

// テ・ツョツ淌ヲツ閉ーテ」ツ?ョテァツャツヲテ・ツ渉キテゥツ鳴「テヲツ閉ー
inline int signum(double x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }
//XYテ・ツコツァテヲツィツ?
#define X real()
#define Y imag()
// テァツつケ
typedef complex<double> P;
 

// テァツキツ堙・ツ按?」ツδサテ・ツ債甘ァツ崢エテァツキツ堙」ツδサテァツ崢エテァツキツ?
struct L { P pos, dir; L(P p=P(), P d=P()):pos(p),dir(d){}};
 
// テ・ツ、ツ堙ィツァツ津・ツスツ「
typedef vector<P> G;
 
// テ・ツ??
struct C { P p; double r; };

// std::norm テ」ツ?ッabs(p)*abs(p)テ」ツ?ェテ」ツ?ョテ」ツ?ァテゥツ??」ツ??
inline double norm(P p){
	return p.X*p.X+p.Y*p.Y;
}

// テ、ツコツ古」ツ?、テ」ツ?ョテ」ツδ凖」ツつッテ」ツδ暗」ツδォテ」ツ?ョテ・ツ??ァツゥツ催」ツつ津ィツィツ暗ァツョツ療」ツ?凖」ツつ?
inline double inp(const P& a, const P& b) {
	return (conj(a)*b).real();
}
 
// テ、ツコツ古」ツ?、テ」ツ?ョテ」ツδ凖」ツつッテ」ツδ暗」ツδォテ」ツ?ョテ・ツ、ツ姪ァツゥツ催」ツつ津ィツィツ暗ァツョツ療」ツ?凖」ツつ?
inline double outp(const P& a, const P& b) {
	return (conj(a)*b).imag();
}

inline int ccw(const P& p, const P& r, const P& s) {
    P a(r-p), b(s-p);
    int sgn = signum(outp(a, b));
    if (sgn != 0)
        return sgn;
    if (a.real()*b.real() < -EPS || a.imag()*b.imag() < -EPS)
        return -1;
    if (norm(a) < norm(b) - EPS)
        return 1;
    return 0;
}

// テ」ツδ凖」ツつッテ」ツδ暗」ツδォpテ」ツつ津」ツδ凖」ツつッテ」ツδ暗」ツδォbテ」ツ?ォテ・ツーツ?・ツスツアテ」ツ?療」ツ?淌」ツδ凖」ツつッテ」ツδ暗」ツδォテ」ツつ津ィツィツ暗ァツョツ療」ツ?凖」ツつ?
inline P proj(const P& p, const P& b) {
	return b*inp(p,b)/norm(b);
}
 
// テァツつケpテ」ツ?凝」ツつ嘉ァツ崢エテァツキツ嗟テ」ツ?ォテ・ツシツ陛」ツ??」ツ?淌・ツ楪づァツキツ堙」ツ?ョティツカツウテ」ツ?ィテ」ツ?ェテ」ツつ凝ァツつケテ」ツつ津ィツィツ暗ァツョツ療」ツ?凖」ツつ?
inline P perf(const L& l, const P& p) {
	L m(l.pos - p, l.dir);
	return (p + (m.pos - proj(m.pos, m.dir)));
}
 
// テァツキツ堙・ツ按?テ」ツつ津ァツ崢エテァツキツ喘テ」ツ?ォテ・ツーツ?・ツスツアテ」ツ?療」ツ?淌ァツキツ堙・ツ按?」ツつ津ィツィツ暗ァツョツ療」ツ?凖」ツつ?
inline L proj(const L& s, const L& b) {
	 return (L){perf(b, s.pos), proj(s.dir, b.dir)};
}
double sp_distance(const L& s, const P& p) {
    const P r = perf(s, p);
    const double pos = ((r-s.pos)/s.dir).real();
    if (-EPS <= pos && pos <= 1 + EPS)
        return abs(r - p);
    return min(abs(s.pos - p),
               abs(s.pos+s.dir - p));
}


double solve(double x1, double x2, double y1, double y2, double l){
	P b1(x1, y1), b2(x2, y1), u1(x1, y2), u2(x2, y2);
	if(sp_distance(L(P(x1, y1), P(x2-x1, 0)), P(0, 0)) > l-EPS) return l*PI*2;
	if(abs(b1)>l+EPS && abs(b2) > l+EPS) return l*(2*PI-acos(y1/l)*2);
	if(x1 <= 0){
		double left=0, right=0;
		double lrest = l, rrest = l;
		if(abs(b1)>l+EPS){
			left = l*(PI-acos(y1/l));
			lrest = 0;
		}else{
			double ang = atan2(y1, x1);
			left += (1.5*PI-ang)*l;
			lrest = l - abs(b1);
			left += (ang-0.5*PI)*lrest;
			lrest = max(.0, lrest - (y2-y1));
		}
		if(abs(b2)>l+EPS){
			right = l*(0.5*PI + asin(y1/l));
			rrest = 0;
			return left + right + lrest*0.5*PI;
		}else{
			double ang = atan2(y1, x2);
			right += (0.5*PI+ang)*l;
			rrest = l - abs(b2);
			
			if(lrest > (x2-x1)+EPS && rrest > (y2-y1)+EPS){
				double ang2 = acos((norm(u2-b1)+rrest*rrest-lrest*lrest)/(2*abs(u2-b1)*rrest)) - atan2(x2-x1, y2-y1);
				if(ang2 > 0){
					right += ((0.5*PI-ang2)-ang)*rrest;
					ang2 = acos((norm(u2-b1)+lrest*lrest-rrest*rrest)/(2*abs(u2-b1)*lrest)) - atan2(y2-y1, x2-x1);
					left += (0.5*PI - ang2)*lrest;
					return left + right;
				}
			}
			right += (0.5*PI-ang)*rrest;
			rrest = max(0.0, rrest - (y2-y1));
			
			if(rrest + lrest > x2-x1+EPS){
				double ang2;
				if(rrest > EPS){
					ang2 = 0.5*PI-acos((norm(b2-b1)+rrest*rrest-lrest*lrest)/(2*(x2-x1)*rrest));
					right += ang2*rrest;
				}
				if(lrest > EPS){
					ang2 = 0.5*PI-acos((norm(b2-b1)+lrest*lrest-rrest*rrest)/(2*(x2-x1)*lrest));
					left += ang2*lrest;
				}
				return left + right;
			}
			
			return right + left + (rrest+lrest)*0.5*PI;
		}
	}else{
		double left=0, right=0;
		double lrest = l, rrest = l;
		double lang, rang;
		if(abs(u1) > l-EPS){
			lang = asin(x1/l);
			left = (PI+lang)*l;
			lrest = 0;
		}else{
			lang = atan2(x1, y2);
			left = (PI+lang)*l;
			lrest = l - abs(u1);
		}
		if(abs(b2) > l-EPS){
			rang = asin(y1/l);
			right = (0.5*PI+rang)*l;
			rrest = 0;
		}else{
			rang = atan2(y1, x2);
			right = (0.5*PI+rang)*l;
			rrest = l - abs(b2);
		}
		
		if(rrest > y2-y1 && lrest > x2-x1){
			double ang2 = acos((norm(u2-b1)+rrest*rrest-lrest*lrest)/(2*abs(u2-b1)*rrest)) - atan2(x2-x1, y2-y1);
			if(ang2 > 0 && acos((norm(u2-b1)+lrest*lrest-rrest*rrest)/(2*abs(u2-b1)*lrest)) - atan2(y2-y1, x2-x1) > 0){
				right += (0.5*PI-rang-ang2)*rrest;
				ang2 = acos((norm(u2-b1)+lrest*lrest-rrest*rrest)/(2*abs(u2-b1)*lrest)) - atan2(y2-y1, x2-x1);
				left += (0.5*PI - lang - ang2)*lrest;
				return left + right;
			}
		}
		
		
		while(lrest > x2-x1 + EPS){
			double Left = left + (0.5*PI-lang)*lrest;
			double Lrest = max(0.0, lrest - (x2-x1));
			if(rrest + Lrest > y2-y1 + EPS){
				if(Lrest < EPS || Lrest + (y2-y1) < rrest) break;
				double ang2;
				ang2 = 0.5*PI-acos((norm(b2-u2)+rrest*rrest-Lrest*Lrest)/(2*(y2-y1)*rrest));
				if(ang2 < 0) break;
				ang2 = 0.5*PI-acos((norm(b2-u2)+Lrest*Lrest-rrest*rrest)/(2*(y2-y1)*Lrest));
				if(ang2 < 0) break;
				if(rrest > EPS){
					ang2 = 0.5*PI-acos((norm(b2-u2)+rrest*rrest-Lrest*Lrest)/(2*(y2-y1)*rrest));
					right += (ang2-rang)*rrest;
				}
				if(Lrest > EPS){
					ang2 = 0.5*PI-acos((norm(b2-u2)+Lrest*Lrest-rrest*rrest)/(2*(y2-y1)*Lrest));
					Left += (ang2)*Lrest;
				}
				return Left + right;
			}
			return right + Left + Lrest*(0.5*PI) + rrest*(0.5*PI-rang);
		}
		while(rrest > y2-y1 + EPS){
			double Right = right + (0.5*PI-rang)*rrest;
			double Rrest = max(0.0, rrest - (y2-y1));
			if(Rrest + lrest > x2-x1 + EPS){
				double ang2;
				if(Rrest < EPS) break;
				ang2 = 0.5*PI-acos((norm(b2-b1)+Rrest*Rrest-lrest*lrest)/(2*(x2-x1)*Rrest));
				if(ang2 < 0) break;
				ang2 = 0.5*PI-acos((norm(b2-b1)+lrest*lrest-Rrest*Rrest)/(2*(x2-x1)*lrest));
				if(ang2 < 0) break;
				if(Rrest > EPS){
					ang2 = 0.5*PI-acos((norm(b2-b1)+Rrest*Rrest-lrest*lrest)/(2*(x2-x1)*Rrest));
					if(ang2 < 0) break;
					Right += ang2*Rrest;
				}
				if(lrest > EPS){
					ang2 = 0.5*PI-acos((norm(b2-b1)+lrest*lrest-Rrest*Rrest)/(2*(x2-x1)*lrest));
					if(ang2 < 0) break;
					left += (ang2-lang)*lrest;
				}
				return left + Right;
			}
			return Right + left + lrest*(0.5*PI-lang) + (Rrest)*0.5*PI;
		}
		
		return right + left + lrest*(0.5*PI-lang) + rrest*(0.5*PI-rang);
	}
	
	return 0;
}

int main(){
	int l, x1, y1, x2, y2;
	while(cin>>l>>x1>>y1>>x2>>y2,l){
		while(y1<=0){
			int px1 = -y1;
			int py1 = x1;
			int px2 = -y2;
			int py2 = x2;
			x1 = px2;
			x2 = px1;
			y1 = py1;
			y2 = py2;
		}
		if(x2 < -x1) swap(x1 = -x1, x2 = -x2);
		printf("%.9f\n", solve(x1, x2, y1, y2, l));
	}
	return 0;
}

Measured memory_bytes: 1312