#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

typedef complex<double> P;
P pIN() { double x,y; cin >> x >> y; return P(x,y); }
namespace std {
  bool operator < (const P& a, const P& b) {
    // if (abs(a-b)<EPS) return 0;
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
bool operator==(const P &a, const P &b) {
  return abs(a-b)<EPS;
}

}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > EPS)   return +1;       // counter clockwise
  if (cross(b, c) < -EPS)   return -1;       // clockwise
  if (dot(b, c) < -EPS)     return +2;       // c--a--b on line
  if (EPS < norm(b) && norm(b) < norm(c)-EPS) return -2; // a--b--c on line
  return 0;
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() { resize(2); }
};
ostream &operator<<(ostream &os, const L &a) {
  os << a[0] << " -> " << a[1];
  return os;
}
typedef vector<P> G;
#define curr(g, i) g[i]
#define next(g, i) g[(i+1)%g.size()]
L line(const G &g, int i) {
  return L(g[i],g[(i+1)%g.size()]);
}
struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
  C() {}
};

struct CS : C {
  P p1, p2;
  CS(const P &p, const P &p1, const P &p2):
    p1(p1),p2(p2) {
    this->p = p;
    this->r = abs(p1);
  }
  L l1() { return L(p,p+p1); }
  L l2() { return L(p,p+p2); }
};

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
P reflection(const L &l, const P &p) {
  return p + P(2,0) * (projection(l, p) - p);
}

vector<P> crosspointLC(const L &l, const C &c) {
  vector<P> ret;
  P center = projection(l, c.p);
  double d = abs(center - c.p);
  double t = sqrt(c.r * c.r - d * d);
  if (::isnan(t)) { return ret; }
  P vect = (l[1] - l[0]);
  vect /= abs(vect);
  ret.push_back(center - vect * t);
  if (t > EPS) {
    ret.push_back(center + vect * t);
  }
  return ret;
}

vector<P> crosspointCC(const C &c1, const C &c2) {
  vector<P> ret;
  double d = abs(c1.p - c2.p);
  if (max(c1.r, c2.r) - min(c1.r, c2.r) - d> -EPS) { return ret; }
  double x = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
  P start = c1.p + (c2.p - c1.p) / d * x;
  P vect = (c1.p - c2.p) * P(0.0, 1.0);
  return crosspointLC(L(start, start + vect), c1);
}
// テ」ツδ凖」ツつッテ」ツδ暗」ツδォテッツスツ?」ツ?凝」ツつ嘉」ツ?ソテ」ツ?淌」ツδ凖」ツつッテ」ツδ暗」ツδォテッツスツづ」ツ?ョティツァツ津・ツコツヲテ」ツ?ョ[0,2pi)
double angle(const P &a, const P &b) {
  double ret = arg(b)-arg(a);
  return (ret>=0) ? ret : ret + 2*PI;
}
// テ」ツδ凖」ツつッテ」ツδ暗」ツδォaテ」ツ?ィテ」ツδ凖」ツつッテ」ツδ暗」ツδォbテ」ツ?ョテゥツ鳴禿」ツ?ョティツァツ津・ツコツヲ
double angle2(const P &a, const P &b) {
  return min(angle(a,b), angle(b,a));
}

bool intersectCSP(const CS &cs, const P &p) {
  return (angle(cs.p1, p-cs.p) <= angle(cs.p1, cs.p2)) &&
    (abs(cs.p-p) <= cs.r+EPS);
}
vector<P> crosspointCSCS(const CS &c1, const CS &c2) {
  vector<P> r = crosspointCC(c1,c2);
  vector<P> res;
  FOR(it, r)
    if (intersectCSP(c1, *it) &&
        intersectCSP(c2, *it))
      res.push_back(*it);
  return res;
}
P rotate(P p, double ang) {
  return p * P(cos(ang), sin(ang));
}
// テ・ツ篠淌ァツつケテ・ツ堕ィテ」ツつ甘」ツ?ョテァツ崢エテァツキツ堙」ツ?ョテ・ツ崢榲ィツサツ「
L rotate(L l, double ang) {
  return L(rotate(l[0], ang),rotate(l[1], ang));
}

FILE *fp;
double scale = 10;
P diff(300, 300);
double WH = 500;
void outputLine(const L &l) {
  if (!fp) return;
  P a = l[0];
  P b = l[1];
  a = a*P(scale,0)+diff;
  b = b*P(scale,0)+diff;
  fprintf(fp,"line(%f,%f,%f,%f);\n",a.real(),WH-a.imag(),b.real(),WH-b.imag());  
}
void outputCircle(C c) {
  if (!fp) return;
  c.p = c.p*P(scale,0) + diff;
  c.r *= scale;
  fprintf(fp, "circle(%f,%f,%f);\n", c.p.real(), WH-c.p.imag(), c.r);
}
void outputCS(const CS &c) {
  if (!fp) return;
  double ang = angle(c.p1,c.p2);
  const int N = 50;
  REP(i,N) {
    double a = ang*i/N;
    double b = ang*(i+1)/N;
    outputLine(L(c.p+rotate(c.p1,a), c.p+rotate(c.p1,b)));
  }
  outputLine(L(c.p,c.p+c.p1));
  outputLine(L(c.p,c.p+c.p2));
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

vector<P> crosspointSC(const L &s, const C &c) {
  vector<P> ret;
  vector<P> nret = crosspointLC(s, c);
  FOR(it, nret)
    if (intersectSP(s, *it))
      ret.push_back(*it);
   return ret;
}
double len;
G g;
vector<CS> solve(int t) {
  L s(P(0,0),P(0,-len));
  vector<CS> res;
  REP(_,4) {
    double minAng = 100;
    P nxt1,nxt2;
    bool f = 0;    
    REP(i,4) {
      if (s[0]==g[i]) continue;
      if (abs(g[i]-s[0])<abs(s[1]-s[0])) {
        double ag = angle(s[1]-s[0],g[i]-s[0]);
        if (t == -1) ag = angle(g[i]-s[0],s[1]-s[0]);
        if (chmin(minAng, ag)) {
          nxt1 = g[i];
          nxt2 = g[i]-s[0];
          nxt2 *= P((abs(s[1]-s[0]) - abs(g[i]-s[0]))/abs(nxt2),0);
          nxt2 += nxt1;
          f = 0;
        }
      }
    }
    REP(i,4) {
      vector<P> ps = crosspointSC(line(g,i),
                                  C(s[0],abs(s[1]-s[0])));
      FOR(it, ps) {
        double ag = angle(s[1]-s[0],*it-s[0]);
        if (t == -1) ag = angle(*it-s[0],s[1]-s[0]);
        if (chmin(minAng, ag)) {
          nxt2 = *it;
          f = 1;
        }
      }
    }
    if (minAng == 100) {
      f = 1;
      nxt2 = P(0,len);
    }
    if (t == -1) 
      res.push_back(CS(s[0],nxt2-s[0],s[1]-s[0]));
    else
      res.push_back(CS(s[0],s[1]-s[0],nxt2-s[0]));
    if (f) break;
    s[0] = nxt1;
    s[1] = nxt2;
  }
  return res;
}

int main() {
  // fp = fopen("data.js", "w");
  double x1,x2,y1,y2;
  while(cin >> len, len) {
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    if (y1 < 0) {
      y1 = -y1;
      y2 = -y2;
      swap(x1,x2);
      swap(y1,y2);
    }
    if (y1 < 0) {
      if (x1 < 0) {
        swap(x1,y1); y1 = -y1;
        swap(x2,y2); y2 = -y2;
      } else {
        swap(x1,y1); x1 = -x1;
        swap(x2,y2); x2 = -x2;
      }
    }
    if (y1 > y2) swap(y1,y2);
    if (x1 > x2) swap(x1,x2);
    g.resize(4);
    g[0] = P(x1,y1);
    g[1] = P(x2,y1);
    g[2] = P(x2,y2);
    g[3] = P(x1,y2);
    vector<CS> v1 = solve(1);
    vector<CS> v2 = solve(-1);

    outputLine(L(P(-1000,0),P(1000,0)));
    outputLine(L(P(0,-1000),P(0,1000)));
    REP(i,4) {
      outputLine(line(g,i));
    }
    REP(i,v1.size()) {
      outputCS(v1[i]);
    }
    REP(i,v2.size()) {
      outputCS(v2[i]);
    }
    
    
    int A=-1,B;
    P cp;
    int hoge = INF;
    REP(i,v1.size()) {
      REP(j,v2.size()) {
        vector<P> v = crosspointCSCS(v1[i],v2[j]);
        if (v.size() == 1 && hoge > i+j) {
          hoge = i+j;
          cp = v[0];
          A = i, B = j;
        }
      }
    }
    double ans = 0;
    if (A >= 0) {
      REP(i,A)
        ans += v1[i].r * angle(v1[i].p1, v1[i].p2);
      REP(i,B)
        ans += v2[i].r * angle(v2[i].p1, v2[i].p2);
      ans += v1[A].r * angle(v1[A].p1, cp-v1[A].p);
      ans += v2[B].r * angle(cp-v2[B].p, v2[B].p2);
    } else {
      REP(i,v1.size())
        ans += v1[i].r * angle(v1[i].p1, v1[i].p2);
      REP(i,v2.size())
        ans += v2[i].r * angle(v2[i].p1, v2[i].p2);
    }
    printf("%.8f\n", ans);
    
  }
}

Measured memory_bytes: 1356