#include <cstdio>
#include <cassert>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;

#define EPS 1e-8
#define EQ(x, y) (abs((x)-(y))<EPS)
#define X real()
#define Y imag()
#define PI 3.1415926535

typedef complex<double> Point;

class Line : public vector<Point> {
public:
  Line () {resize(2);}
  Line (Point a, Point b) {
    push_back(a);
    push_back(b);
  }
};

struct Circle {
  Point c;
  double r;
};

namespace std {
  bool operator<(Point a, Point b) {
    if (a.X != b.X) return a.X < b.X;
    return a.Y < b.Y;
  }
}

double dot(Point a, Point b) {
  return (conj(a)*b).X;
}

double cross(Point a, Point b) {
  return (conj(a)*b).Y;
}

int ccw(Point a, Point b, Point c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0) return 1;
  if (cross(b, c) < 0) return -1;
  if (dot(b, c) < 0) return 2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}

Point proj(Line l, Point p) {
  Point v = l[1]-l[0];
  double ratio = dot(v, p-l[0]) / norm(v);
  return l[0] + ratio*v;
}

double DistLP(Line l, Point p) {
  return abs(p - proj(l, p));
}

vector<Point> CrossPointCL(Circle c, Line l){
  vector<Point> ret;
  double d = DistLP(l, c.c);
  if(d < c.r + EPS){
    double ratio = (d > c.r) ? 0.0 : sqrt(c.r*c.r - d*d);
    Point sgn = (l[0] - l[1]) / abs(l[0] - l[1]);
    ret.push_back(proj(l, c.c) + ratio * sgn);
    ret.push_back(proj(l, c.c) - ratio * sgn);
  }

  return ret;
}

vector<Point> CrossPointCS(Circle c, Line s){
  vector<Point> ret;
  vector<Point> res = CrossPointCL(c, s);
  for (int i=0; i<res.size(); i++) {
    if(ccw(s[0], res[i], s[1]) == -2) ret.push_back(res[i]);
  }
  return ret;
}

vector<Point> CrossPointCC(Circle c1, Circle c2){
  vector<Point> ret;
  double d = abs(c1.c - c2.c);
  double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
  double dfr = c1.r*c1.r - rc*rc;

  if (EQ(dfr, 0.0)) dfr = 0.0;
  else if(dfr < 0.0) return ret;

  double rs = sqrt(dfr);
  Point sgn = (c2.c - c1.c) / d;
  ret.push_back(c1.c + sgn*Point(rc, rs));
  if (dfr > 0.0) ret.push_back(c1.c + sgn*Point(rc, -rs));
  return ret;
}

vector<Point> GrahamScan(vector<Point> ps) {
  int k = 0;
  int n = ps.size();
  vector<Point> ret(n*2);

  sort(ps.begin(), ps.end());
  for (int i=0; i<n; i++) {
    while (k > 1 && ccw(ret[k-2], ret[k-1], ps[i]) != 1) k--;
    ret[k++] = ps[i];
  }

  int k_ = k;
  for (int i=n-1; i>=0; i--) {
    while (k > k_ && ccw(ret[k-2], ret[k-1], ps[i]) != 1) k--;
    ret[k++] = ps[i];
  }

  ret.resize(k-1);
  return ret;
}

double Normilize(double t) {
  if (t < -EPS) t += PI;
  return t;
}

double len;
double xs[2];
double ys[2];

int main() {
  while (1) {
    scanf("%lf", &len);
    if (len == 0.0) return 0;

    for (int i=0; i<2; i++) {
      scanf("%lf%lf", &xs[i], &ys[i]);
    }

    vector<Point> ps;
    vector<Point> qs;
    vector<Line> segs;
    Point o(0, 0);

    for (int i=0; i<2; i++) {
      for (int j=0; j<2; j++) {
        ps.push_back(Point(xs[i], ys[j]));
      }
    }

    for (int i=0; i<4; i++) {
      for (int j=i+1; j<4; j++) {
        if (ps[i].X == ps[j].X || ps[i].Y == ps[j].Y) {
          segs.push_back(Line(ps[i], ps[j]));
        }
      }
    }

    ps.push_back(o);
    qs = GrahamScan(ps);

    int n = qs.size();

    int b;
    for (int i=0; i<n; i++) {
      if (qs[i] == o) b = i;
    }

    double cur_len = len;
    vector<Circle> ccw_ps;
    ccw_ps.push_back({o, cur_len});
    for (int i=1; i<n; i++) {
      Point p = qs[(b+i-1)%n];
      Point q = qs[(b+i)%n];
      if (abs(q-p) > cur_len) {
        vector<Point> cand;
        for (int j=0; j<4; j++) {
          Circle c = {p, cur_len};
          vector<Point> res = CrossPointCS(c, segs[j]);
          cand.insert(cand.end(), res.begin(), res.end());
        }

        double mint = 10e10;
        Point cp(mint, mint);
        for (int j=0; j<cand.size(); j++) {
          double t = Normilize(arg((cand[j]-p)/(q-p)));
          if (t < mint) {
            mint = t;
            cp = cand[j];
          }
        }
        
        ccw_ps.push_back({cp, 0.0});
        break;
      }

      cur_len -= abs(q-p);
      ccw_ps.push_back({q, cur_len});
    }

    vector<Circle> cw_ps;
    cur_len = len;
    cw_ps.push_back({o, cur_len});
    for (int i=1; i<n; i++) {
      Point p = qs[(n+b-i+1)%n];
      Point q = qs[(n+b-i)%n];
      if (abs(q-p) > cur_len) {
        vector<Point> cand;
        for (int j=0; j<4; j++) {
          Circle c = {p, cur_len};
          vector<Point> res = CrossPointCS(c, segs[j]);
          cand.insert(cand.end(), res.begin(), res.end());
        }

        double mint = 10e10;
        Point cp(mint, mint);
        for (int j=0; j<cand.size(); j++) {

          double t = Normilize(arg((q-p)/(cand[j]-p)));
          if (t < mint) {
            mint = t;
            cp = cand[j];
          }
        }
        
        cw_ps.push_back({cp, 0.0});
        break;
      }

      cur_len -= abs(q-p);
      cw_ps.push_back({q, cur_len});
    }

    for (int i=0; i<cw_ps.size(); i++) {
      for (int j=0; j<ccw_ps.size(); j++) {
        if (cw_ps[i].c == ccw_ps[j].c) continue;
        vector<Point> cs = CrossPointCC(cw_ps[i], ccw_ps[j]);
        for (int k=0; k<cs.size(); k++) {
          Point a = ccw_ps[j].c;
          Point b = cs[k];
          Point c = cw_ps[i].c;
          if (ccw(a, b, c) > 0) {
            Point d = ccw_ps[(j+1)%ccw_ps.size()].c;
            Point e = cw_ps[(i+1)%cw_ps.size()].c;
            if (ccw(a, b, d) > 0 && ccw(e, b, c) > 0) {
              assert(i+1 < cw_ps.size());
              assert(j+1 < ccw_ps.size());
              cw_ps[i+1] = {cs[k], 0.0};
              ccw_ps[j+1] = {cs[k], 0.0};
              goto L_CALC_ANS;
            }
          }
        }
      }
    }

L_CALC_ANS:
    double ans = 0.0;
    for (int i=1; i<cw_ps.size(); i++) {
      if (cw_ps[i].r == 0.0) break;

      Point a = cw_ps[i-1].c;
      Point b = cw_ps[i].c;
      Point c = cw_ps[i+1].c;
      ans += cw_ps[i].r * Normilize(arg((b-a)/(c-b)));
    }

    for (int i=1; i<ccw_ps.size(); i++) {
      if (ccw_ps[i].r == 0.0) break;

      Point a = ccw_ps[i-1].c;
      Point b = ccw_ps[i].c;
      Point c = ccw_ps[i+1].c;
      ans += ccw_ps[i].r * Normilize(arg((c-b)/(b-a)));
    }

    ans += (2*PI - abs(arg(cw_ps[1].c/ccw_ps[1].c))) * len;
    printf("%f\n", ans);
  }
}

Measured memory_bytes: 2908