// Watchdog Corporation

////////////////////
// ???????????????
#include<cmath>
#include<algorithm>
#include<cassert>
////////////////////
// ??¨????????¢???
using D = double;
////////////////////
// ?????°
const D EPS = 1e-9;                // |EPS|???????????°???0??¨????????±???
enum POSITION {ONLINE_FRONT = -2, CLOCKWISE, ON_SEGMENT, COUNTER_CLOCKWISE, ONLINE_BACK};   // 3??????????????¢???
////////////////////
// ?§???????
struct Point {
  D x, y;
  Point(const D d = 0.0) : x(d), y(d) {}
  Point(const D x, const D y) : x(x), y(y) {}
};
struct Segment {
  Point from, to;
  Segment(const Point& from, const Point& to) : from(from), to(to) {}
  Segment(const D x1, const D y1, const D x2, const D y2) : from(x1, y1), to(x2, y2) {}
};
struct Line {
  Point from, to;
  Line(const Point& from, const Point& to) : from(from), to(to) {}
  Line(const D x1, const D y1, const D x2, const D y2) : from(x1, y1), to(x2, y2) {}
  Line(const Segment& s) : from(s.from), to(s.to) {}
};
////////////////////
// ????£?
bool relative_equal(const D d1, const D d2) {return d1 == 0 ? std::abs(d2) < EPS : std::abs((d1 - d2) / d1) < EPS;}
// ??????????????????????????????
bool operator==(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) && relative_equal(lhs.y, rhs.y);}
bool operator<(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) ? lhs.y < rhs.y : lhs.x < rhs.x;}
bool operator>(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) ? lhs.y > rhs.y : lhs.x > rhs.x;}
bool operator!=(const Point& lhs, const Point& rhs) {return !(lhs == rhs);}
bool operator<=(const Point& lhs, const Point& rhs) {return !(lhs > rhs);}
bool operator>=(const Point& lhs, const Point& rhs) {return !(lhs < rhs);}
const Point operator+(const Point& lhs, const Point& rhs) {return Point(lhs.x + rhs.x, lhs.y + rhs.y);}
const Point operator-(const Point& lhs, const Point& rhs) {return Point(lhs.x - rhs.x, lhs.y - rhs.y);}
const Point operator*(const Point& lhs, const Point& rhs) {return Point(lhs.x * rhs.x, lhs.y * rhs.y);}
const Point operator/(const Point& lhs, const Point& rhs) {return Point(lhs.x / rhs.x, lhs.y / rhs.y);}
const Point operator-(const Point& p) {return Point(-p.x, -p.y);}
// ???
D abs(const Point& p) {return std::hypot(p.x, p.y);}
D norm(const Point& p) {return p.x * p.x + p.y * p.y;}
D dot(const Point& a, const Point& b) {return a.x * b.x + a.y * b.y;}
D cross(const Point& a, const Point& b) {return a.x * b.y - a.y * b.x;}
// ??´???
bool parallel(const Line& l1, const Line& l2) {return relative_equal(0.0, cross(l2.to - l2.from, l1.to - l1.from));}
bool orthogonal(const Line& l1, const Line& l2) {return relative_equal(0.0, dot(l2.to - l2.from, l1.to - l1.from));}
// 3??????????????¢???
POSITION ccw(const Point& a, const Point& b, const Point& p) {
  Point v1 = b - a;
  Point v2 = p - a;
  if(cross(v1, v2) >= EPS) return COUNTER_CLOCKWISE;
  if(cross(v1, v2) <= -EPS) return CLOCKWISE;
  if(dot(v1, v2) <= -EPS) return ONLINE_BACK;
  if(norm(v1) < norm(v2)) return ONLINE_FRONT;              // ????????????: norm(v1)<norm(v2)+EPS?????¨WrongAnswer
  return ON_SEGMENT;
}
// ????????????
bool intersect(const Point& p1, const Point& p2) {return p1 == p2;}
bool intersect(const Point& p, const Segment& s) {return abs(p - s.from) + abs(p - s.to) - abs(s.from - s.to) <= EPS;}
bool intersect(const Segment& s, const Point& p) {return intersect(p, s);}
bool intersect(const Point& p, const Line& l) {return !parallel(Line(p, l.from), Line(p, l.to));}
bool intersect(const Line& l, const Point& p) {return intersect(p, l);}
bool intersect(const Segment& s1, const Segment& s2) {
  return ccw(s1.from, s1.to, s2.from) * ccw(s1.from, s1.to, s2.to) <= 0
      && ccw(s2.from, s2.to, s1.from) * ccw(s2.from, s2.to, s1.to) <= 0;
}
bool intersect(const Segment& s, const Line& l) {
  auto v1 = l.to - l.from;
  auto v2 = s.from  - l.from;
  auto v3 = s.to - l.from;
  return cross(v1, v2) * cross(v1, v3) <= EPS;
}
bool intersect(const Line& l, const Segment& s) {return intersect(s, l);}
bool intersect(const Line& l1, const Line& l2) {return !parallel(l1, l2) || intersect(l1.from, l2);}
// ???????§????
Point rotate(const Point& p, const D a) {return Point(p.x * std::cos(a) - p.y * std::sin(a), p.x * std::sin(a) + p.y * std::cos(a));}
Point projection(const Point& p, const Line& l) {
  auto v = l.from - l.to;
  return l.from + dot(p - l.from, v) / norm(v) * v;
}
Point projection(const Line& l, const Point& p) {return projection(p, l);}
Point reflection(const Point& p, const Line& l) {return p + 2 * (projection(p, l) - p);}
Point reflection(const Line& l, const Point& p) {return reflection(p, l);}
// ?????¢
D distance(const Point& p1, const Point& p2) {
  auto p = p1 - p2;
  return hypot(p.x, p.y);
}
D distance(const Point& p, const Segment& s) {
  auto r = projection(s, p);
  return intersect(r, s) ? distance(p, r) : std::min(distance(p, s.from), distance(p, s.to));
}
D distance(const Segment& s, const Point& p) {return distance(p, s);}
D distance(const Point& p, const Line& l) {return distance(p, projection(p, l));}
D distance(const Line& l, const Point& p) {return distance(p, l);}
D distance(const Segment& s1, const Segment& s2) {
  return intersect(s1, s2) ? 0.0 : std::min({distance(s1, s2.from), distance(s1, s2.to), distance(s2, s1.from), distance(s2, s1.to)});
}
D distance(const Segment& s, const Line& l) {return intersect(s, l) ? 0.0 : std::min(distance(s.from, l), distance(s.to, l));}
D distance(const Line& l,const Segment& s) {return distance(s, l);}
D distance(const Line& l1, const Line& l2) {return intersect(l1, l2) ? 0.0 : distance(l1.from, l2);}
// ??????
const Point crosspoint(const Line& l1, const Line& l2) {
  assert(intersect(l1, l2));
  if(parallel(l1, l2)) return l1.from;                   // ???????????¨???l1????§?????????????
  D A = cross(l1.to - l1.from, l2.to - l2.from);
  D B = cross(l1.to - l1.from, l1.to - l2.from);
  return l2.from + B / A * (l2.to - l2.from);
}
const Point crosspoint(const Segment& s, const Line& l) {
  assert(intersect(s, l));
  if(parallel(s, l)) return s.from;
  return crosspoint(Line(s), l);
}
const Point crosspoint(const Line& l, const Segment& s) {return crosspoint(s, l);}
const Point crosspoint(const Segment& s1, const Segment& s2) {
  assert(intersect(s1, s2));
  if(parallel(s1, s2)) {                                    // ???????????¨?????????????????????????????????
    if(intersect(s1.from,  s2)) return s1.from;
    if(intersect(s1.to, s2)) return s1.to;
    if(intersect(s2.from,  s1)) return s2.from;
    if(intersect(s2.to, s1)) return s2.to;
  }
  return crosspoint(Line(s1), Line(s2));
}
// ???????????°??¨
#include<iostream>
std::ostream& operator<<(std::ostream& os, const Point& p) {os<<"point: "; os<<"("<<p.x<<","<<p.y<<")"; return os;}
std::ostream& operator<<(std::ostream& os, const Segment& s) {os<<"segment: "; os<<s.from<<" - "<<s.to; return os;}
std::ostream& operator<<(std::ostream& os, const Line& l) {os<<"line: "; os<<l.from<<" - "<<l.to; return os;}
////////////////////////////////////////////////////////////////////////////////
// ???
#include<vector>
const D PI = std::acos(-1);
struct Circle {
  Point center;
  D radius;
  Circle(const Point& center = 0, const D radius = 1) : center(center), radius(radius) {}
  Circle(const D x, const D y, const D radius) : center(x, y), radius(radius) {}
};
// ????????¢???
bool contain(const Circle& c, const Point& p) {
  D d = distance(c.center, p);
  if(relative_equal(c.radius, d)) return true;
  return d < c.radius;
}
bool contain(const Point& p, const Circle& c) {return contain(c, p);}
// ??±?????\???
int tangent(const Circle& c1, const Circle& c2) {
  D d = distance(c1.center, c2.center);
  D r = c1.radius + c2.radius;
  if(relative_equal(d, r)) return 3;    // ?????\
  if(r < d) return 4;                   // ?????¢
  r = std::abs(c1.radius - c2.radius);
  if(relative_equal(d, r)) return 1;    // ?????\
  if(r < d) return 2;                   // ??????
  return 0;                             // ??????
}
// ??????
std::vector<Point> crosspoint(const Circle& c, const Line& l) {
  std::vector<Point> cp;
  Point p = projection(c.center, l);
  if(!contain(c, p)) return cp;
  Point v = p - c.center;
  if(relative_equal(abs(v), 0)) {
    Point p = l.from - c.center;
    if(p == 0) p = l.to - c.center;
    p = (c.radius * p / abs(p));
    cp.push_back(c.center + p);
    cp.push_back(c.center - p);
    return cp;
  }
  D angle = acos(abs(v) / c.radius);
  for(D a: {angle, -angle}) cp.push_back(c.center + c.radius * (rotate(v, a) / abs(v)));
  return cp;
}
std::vector<Point> crosspoint(const Line& l, const Circle& c) {return crosspoint(c, l);}
std::vector<Point> crosspoint(const Circle& c1, const Circle& c2) {
  assert(tangent(c1, c2) != 4);
  std::vector<Point> cp;
  D angle = atan2(c2.center.y - c1.center.y, c2.center.x - c1.center.x);
  D d = distance(c1.center, c2.center);
  D add = acos((d * d + c1.radius * c1.radius - c2.radius * c2.radius) / (2.0 * d * c1.radius));
  for(D a: {angle + add, angle - add}) cp.push_back(c1.center + c1.radius * Point(std::cos(a), std::sin(a)));
  return cp;
}
// ?????¨
D circumference(const Circle& c) {return 2.0 * PI * c.radius;}
// ?????§
D arc(const Circle& c, const Point& a, const Point& b) {return c.radius * acos(dot(a - c.center, b - c.center) / abs(a - c.center) / abs(b - c.center));}

#include<bits/stdc++.h>
using namespace std;

D solve(auto len, auto x1, auto y1, auto x2, auto y2) {
//   cout<<setprecision(0)<<fixed<<len<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
  // 0 < y1 < y2
  // x1 < x2
  // 0 < x2
  // |x1| < |x2|
  if(x1 <= 0 && x2 <= 0) {
    x1 = -x1;
    x2 = -x2;
  }
  if(y1 <= 0 && y2 <= 0) {
    y1 = -y1;
    y2 = -y2;
  }
  if(x1 > x2) swap(x1, x2);
  if(y1 > y2) swap(y1, y2);
  if(y1 <= 0) {
    swap(x1, y1);
    swap(x2, y2);
  }
  if(x1 * x2 < 0 && abs(x1) > abs(x2)) {
    x1 = -x1;
    x2 = -x2;
  }
  if(x1 > x2) swap(x1, x2);

  Point ul(x1, y2), ur(x2, y2), lr(x2, y1),ll(x1, y1);
  Segment top(ul, ur), right(ur, lr), bottom(lr, ll), left(ll, ul);
  Circle dog(0, 0, len);

  D res = circumference(dog);

  // ?£?????§??????????
  if(dog.radius <= distance(dog.center, bottom) + EPS) return res;
  // ????´???¨????´????????£?
  if(dog.radius <= distance(dog.center, ll) + EPS && dog.radius <= distance(dog.center, lr) + EPS) {
    auto cp = crosspoint(dog, bottom);
    return res - arc(dog, cp.front(), cp.back());
  }
  // ??????????¬¬????±????
  if(0 <= ll.x) {
    // ????´????????£?
    if(dog.radius <= distance(dog.center, ul) + EPS) {
      Point l;
      for(auto p: crosspoint(dog, left)) if(0 < p.y) l = p;
      // ????´????????£?
      if(dog.radius <= distance(dog.center, lr) + EPS) {
        Point r;
        for(auto p: crosspoint(dog, bottom)) if(ll.x <= p.x + EPS) r = p;
        return res - arc(dog, l, r);
      }
      // ????´????????£?
      Circle clr(lr, dog.radius - distance(dog.center, lr));
      Point endlr;
      for(auto p: crosspoint(dog, Line(dog.center, lr))) if(0 < p.y) endlr = p;
      Point r(clr.center.x, clr.center.y + clr.radius);
      return res - arc(dog, l, endlr) + arc(clr, endlr, r);
    }
    // ????´????????£?
    Circle cul(ul, dog.radius - distance(dog.center, ul));
    Point endul;
    for(auto p: crosspoint(dog, Line(dog.center, ul))) if(0 < p.y) endul = p;
    if(cul.radius <= distance(ul, ur) + EPS) {
      Point l(cul.center.x + cul.radius, cul.center.y);
      // ????´????????£?
      if(dog.radius <= distance(dog.center, lr) + EPS) {
        Point r;
        for(auto p: crosspoint(dog, bottom)) if(ll.x <= p.x + EPS) r = p;
        return res - arc(dog, endul, r) + arc(cul, endul, l);
      }
      // ????´????????£?
      Circle clr(lr, dog.radius - distance(dog.center, lr));
      Point endlr;
      for(auto p: crosspoint(dog, Line(dog.center, lr))) if(0 < p.y) endlr = p;
      if(clr.radius <= distance(lr, ur) + EPS) {
        Point r(clr.center.x, clr.center.y + clr.radius);
        return res - arc(dog, endul, endlr) + arc(cul, endul, l) + arc(clr, endlr, r);
      }
      // ????£???§???????????????
      Circle cur(ur, clr.radius - distance(lr, ur));
      Point endur(cur.center.x, cur.center.y + cur.radius);
      Point r(cur.center.x - cur.radius, cur.center.y);
      if(l.x <= r.x + EPS) return res - arc(dog, endul, endlr) + arc(cul, endul, l) + arc(clr, endlr, endur) + arc(cur, endur, r);
    }
    // ????´????????£?
    Circle cur(ur, cul.radius - distance(ul, ur));
    Point endur(cur.center.x + cur.radius, cur.center.y);
    Circle clr(lr, dog.radius - distance(dog.center, lr));
    Point endlr;
    for(auto p: crosspoint(dog, Line(dog.center, lr))) if(0 < p.y) endlr = p;
    if(cur.radius <= distance(ur, lr) + EPS) {
      // ????´????????£?
      if(clr.radius <= distance(ur, lr) + EPS) {
        // ????£???§???????????????
        Point l(cur.center.x, cur.center.y - cur.radius);
        Point r(clr.center.x, clr.center.y + clr.radius);
        if(r.y <= l.y + EPS) return res - arc(dog, endul, endlr) + arc(cul, endul, endur) + arc(cur, endur, l) + arc(clr, endlr, r); 
      }
    }
    // ?????????????????§?????????
    for(auto p: crosspoint(cul, clr)) if(ur.x <= p.x + EPS && ur.y <= p.y + EPS) return res - arc(dog, endul, endlr) + arc(cul, endul, p) + arc(clr, endlr, p);
    // ??????????????§?????????
    for(auto p: crosspoint(cul, clr)) if(ur.y <= p.y + EPS) {
      Circle c(ur, clr.radius - distance(ur, lr));
      Point e(c.center.x, c.center.y + c.radius);
      for(auto p: crosspoint(cul, c)) if(ur.y <= p.y + EPS) return res - arc(dog, endul, endlr) + arc(cul, endul, p) + arc(clr, endlr, e) + arc(c, e, p);
      assert(false);
    }
    // ??????????????§?????????
    for(auto p: crosspoint(cur, clr)) if(ur.x <= p.x + EPS) return res - arc(dog, endul, endlr) + arc(cul, endul, endur) + arc(cur, endur, p) + arc(clr, endlr, p);
    assert(false);
  // ??????????¬¬????±??????¨?¬¬????±???????????????????
  } else {
    // ????´????????£?
    Circle cll(ll, dog.radius - distance(dog.center, ll));
    Point endll;
    for(auto p: crosspoint(dog, Line(dog.center, ll))) if(0 < p.y) endll = p;
    if(cll.radius <= distance(ll, ul) + EPS) {
      Point l(cll.center.x, cll.center.y + cll.radius);
      // ????´????????£?
      if(dog.radius <= distance(dog.center, lr) + EPS) {
        Point r;
        for(auto p: crosspoint(dog, bottom)) if(ll.x <= p.x + EPS) r = p;
        return res - arc(dog, endll, r) + arc(cll, endll,l);
      }
      // ????´????????£?
      Circle clr(lr, dog.radius - distance(dog.center, lr));
      Point endlr;
      for(auto p: crosspoint(dog, Line(dog.center, lr))) if(0 < p.y) endlr = p;
      Point r(clr.center.x, clr.center.y + clr.radius);
      return res - arc(dog, endll, endlr) + arc(cll, endll, l) + arc(clr, endlr, r);
    }
    // ????´????????£?????¶???????
    Circle cul(ul, cll.radius - distance(ll, ul));
    Point endul(cul.center.x, cul.center.y + cul.radius);
    // ????´????????£?
    if(dog.radius <= distance(dog.center, lr)) {
      Point l(cul.center.x + cul.radius, cul.center.y);
      Point r;
      for(auto p: crosspoint(dog, bottom)) if(ll.x <= p.x + EPS) r = p;
      return res - arc(dog, endll, r) + arc(cll, endll, endul) + arc(cul, endul, l);
    }
    // ????´????????£?
    Circle clr(lr, dog.radius - distance(dog.center, lr));
    Point endlr;
    for(auto p: crosspoint(dog, Line(dog.center, lr))) if(0 < p.y) endlr = p;
    res -= arc(dog, endll, endlr);
    if(clr.radius <= distance(lr, ur) + EPS) {
      // ????´????????£?
      if(cul.radius <= distance(ul, ur) + EPS) {
        Point l(cul.center.x + cul.radius, cul.center.y);
        Point r(clr.center.x, clr.center.y + clr.radius);
        return res + arc(cll, endll, endul) + arc(cul, endul, l) + arc(clr, endlr, r);
      }
      // ????´????????£?
      Circle c(ur, cul.radius - distance(ul, ur));
      Point e(c.center.x, c.center.y + c.radius);
      if(c.radius <= distance(ur, lr) + EPS) {
        Point l(c.center.x, c.center.y - c.radius);
        Point r(clr.center.x, clr.center.y + clr.radius);
        if(r.y <= l.y + EPS) return res + arc(cll, endll, endul) + arc(cul, endul, e) + arc(c, e, l) + arc(clr, endlr, r);
      }
    }
    // ????´????????£?????¶???????
    Circle cur(ur, clr.radius - distance(lr, ur));
    Point endur(cur.center.x, cur.center.y + cur.radius);
    // ????£???§???????????????
    if(cul.center.x + cul.radius <= cur.center.x - cur.radius + EPS) {
      Point l(cul.center.x + cul.radius, cul.center.y);
      Point r(cur.center.x - cur.radius, cur.center.y);
      return res + arc(cll, endll, endul) + arc(cul, endul, l) + arc(clr, endlr, endur) + arc(cur, endur, r);
    }
    // ??????????????§?????????
    for(auto p: crosspoint(cul, cur)) if(ur.y <= p.y + EPS)
      if(ul.x <= p.x + EPS && p.x <= ur.x + EPS)
        return res + arc(cll, endll, endul) + arc(cul, endul, p) + arc(clr, endlr, endur) + arc(cur, endur, p);
    // ?????????????????§?????????
    for(auto p: crosspoint(cll, cur))
      if(p.x <= ul.x + EPS && ul.y <= p.y + EPS)
        return res + arc(cll, endll, p) + arc(clr, endlr, endur) + arc(cur, endur, p);
    // ?????????????????§?????????
    for(auto p: crosspoint(cul, clr))
      if(ur.x <= p.x + EPS && ur.y <= p.y + EPS) 
        return res + arc(cll, endll, endul) + arc(cul, endul, p) + arc(clr, endlr, p);
    // ??????????????§?????????
    Circle c(ur, cul.radius - distance(ul, ur));
    Point e(c.center.x, c.center.y + c.radius);
    for(auto p: crosspoint(c, clr)) if(ur.x <= p.x + EPS) return res + arc(cll, endll, endul) + arc(cul, endul, e) + arc(c, e, p) + arc(clr, endlr, p);
  }
  assert(false);
}

int main() {
  D len, x1, y1, x2, y2;
  while(cin >> len >> x1 >> y1 >> x2 >> y2, len) cout << setprecision(6) << fixed << solve(len, x1, y1, x2, y2) << endl;
}

Measured memory_bytes: 3648