#include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) begin(x),end(x)

using namespace std;

typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-9, pi = acos((ld)-1.0), INF = 1e+8;

#define EQ(a,b) (abs((a)-(b))<eps)

ld dot (P a, P b) { return real(conj(a) * b); }
ld cross (P a, P b) { return imag(conj(a) * b); }

namespace std {
  bool operator<(const P &lhs, const P &rhs) {
    return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag() : lhs.real() < rhs.real();
  }
}

// Line
class L{
public:
  P a, b;
  L (P aa, P bb) { a = aa; b = bb; }
  L (ld ax, ld ay, ld bx, ld by) { a = P(ax, ay); b = P(bx, by); }
};

// Circle
class C { public: P p; ld r; };

// counter clockwise
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) < 0) return 2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line
  return 0;                          // a--c--b on line
}

bool isis_ss(L s, L t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) < 0 &&
         ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) < 0;
}

P is_ll(L s, L t){
  P sv = s.b - s.a, tv = t.b - t.a;
  return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

VP is_cc(C c1, C c2){
  VP res;
  ld d = abs(c1.p - c2.p);
  ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
  ld dfr = c1.r * c1.r - rc * rc;
  if (abs(dfr) < eps) dfr = 0.0;
  else if (dfr < 0.0) return res; // no intersection
  ld rs = sqrt(dfr);
  P diff = (c2.p-c1.p)/d;
  res.push_back(c1.p + diff * P(rc, rs));
  if (dfr != 0.0) res.push_back(c1.p + diff * P(rc, -rs));
  return res;
}

P proj(L l, P p) {
  ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}

ld dist_lp(L l, P p) {
  return abs(p - proj(l, p));
}

VP is_lc(C c, L l){
  VP res;
  ld d = dist_lp(l, c.p);
  if (d < c.r + eps){
    ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); //safety;
    P nor = (l.a - l.b) / abs(l.a - l.b);
    res.push_back(proj(l, c.p) + len * nor);
    res.push_back(proj(l, c.p) - len * nor);
  }
  return res;
}

bool isis_sp(L s, P p) {
  return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}

VP is_sc(C c, L l){
  VP v = is_lc(c, l), res;
  for (P p : v)
    if (isis_sp(l, p)) res.push_back(p);
  return res;
}

vector<L> house;
vector<P> hp;
ld dd[5][5];
ld x[2],y[2];

bool is_ok(P p, P o=P()) {
  REP(i,4) if (isis_ss(house[i], L(p, o))) return false;
  return true;
}

bool is_in_h(P p) {
  return x[0] < real(p) && real(p) < x[1] &&
    y[0] < imag(p) && imag(p) < y[1];
}

ld dist(P p) {
  ld minl = INF;
  if(is_in_h(p)) return INF;
  REP(i,5) if(is_ok(p,hp[i])) minl=min(minl,dd[0][i]+abs(p-hp[i]));
  return minl;
}

int main() {
  random_device rg;
  mt19937 mt(rg());
  while(1){
    house.clear(); hp.clear();
    ld l;
    cin>>l>>x[0]>>y[0]>>x[1]>>y[1];
    if(!l) break;
    REP(i,2)REP(j,2) hp.emplace_back(x[i],y[j]);
    REP(i,5)REP(j,5) dd[i][j] = INF;
    REP(i,2){
      house.emplace_back(hp[i],hp[i+2]);
      house.emplace_back(hp[i*2],hp[i*2+1]);
      dd[i+1][i+3] = x[1]-x[0];
      dd[i*2+1][i*2+2] = y[1]-y[0];
    }
    REP(i,4) if(is_ok(hp[i])) dd[0][i+1] = abs(hp[i]);
    hp.insert(begin(hp),P());
    REP(i,5)REP(j,i) dd[i][j] = dd[j][i];
    REP(i,5) dd[i][i]=0;
    REP(k,5)REP(i,5)REP(j,5) dd[i][j]=min(dd[i][j],dd[i][k]+dd[k][j]);
    vector<C> vc;
    REP(i,5) vc.push_back((C){hp[i], l-dd[0][i]});
    VP crs;
    REP(i,5)REP(j,i){
      auto v=is_cc(vc[i],vc[j]);
      crs.insert(end(crs),ALL(v));
    }
    REP(i,5)REP(j,4){
      auto v=is_sc(vc[i],house[j]);
      crs.insert(end(crs),ALL(v));
    }
    ld res = 0;
    REP(i,5){
      vector<ld> va;
      REP(j,crs.size())
        if(abs(abs(crs[j]-hp[i])-vc[i].r) < eps)
          va.emplace_back(arg(crs[j]-hp[i]));
      sort(ALL(va));
      REP(j,va.size()-1){
        uniform_real_distribution<ld> dis(va[j],va[j+1]);
        ld rad = va[j+1]-va[j];
        P p=polar(vc[i].r, dis(mt))+hp[i];
        if (abs(dist(p)-l) < eps) res += rad*vc[i].r;
      }
      if(va.size()>=2){
        uniform_real_distribution<ld> dis(va.back(),va.front()+pi*2);
        ld rad = pi*2-(va.back()-va.front());
        assert(rad>=0);
        P p=polar(vc[i].r, dis(mt))+hp[i];
        if (abs(dist(p)-l) < eps) res += rad*vc[i].r;
      }
    }
    cout<<setprecision(8)<<fixed<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 1364