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

typedef complex<double> P;
typedef pair<P,P> L;

const double INF = 1e+12;
const double EPS = 1e-8;

struct Rect {
  P p[4]; //????????????????¨???????
  Rect(double x1=0, double y1=0, double x2=0, double y2=0){
    if(x1 > x2) swap(x1, x2);
    if(y1 > y2) swap(y1, y2);
    p[0] = P(x1, y1);
    p[1] = P(x1, y2);
    p[2] = P(x2, y2);
    p[3] = P(x2, y1);
  }
};

struct Circle{
  P c; 
  double r;
  Circle(P c=P(0,0), double r=0):c(c),r(r){}
};

bool equal(double a, double b){
  return fabs(a-b) < EPS;
}

P rotate(P p, double rad){
  double x = real(p) * cos(rad) - imag(p) * sin(rad);
  double y = real(p) * sin(rad) + imag(p) * cos(rad);
  return P(x,y);
}

double dot(P a, P b){ return real(conj(a)*b); }

bool isIntersectSP(L s, P p){ 
  return abs(s.first-p) + abs(s.second-p) - abs(s.second-s.first) < EPS; 
}

P proj(P p, L l){
  return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);
}

vector<P> getIntersectCS(Circle c, L s){
  vector<P> res;
  P h = proj(c.c, s);
  double d = abs(c.c - h);
  if(d > c.r + EPS);
  else if(d > c.r - EPS){
    if(isIntersectSP(s,h)) res.push_back(h);
  }
  else {
    P v = s.second - s.first;
    v = (sqrt(c.r*c.r - d*d) / abs(v)) * v;
    if(isIntersectSP(s, h+v)) res.push_back(h+v);
    if(isIntersectSP(s, h-v)) res.push_back(h-v);
  }
  return res;
}

vector<P> getIntersectCC(Circle c1, Circle c2){
  vector<P> res;
  double r1 = c1.r, r2 = c2.r, d;
  P p1 = c1.c, p2 = c2.c;
  d = abs(p1-p2);

  if(d < EPS && abs(r1-r2) < EPS) return res; //????????¨?????????????????´???????????????????????????????????????
  if(r1 + r2< d - EPS || d + EPS < abs(r1-r2)) return res; //???????????????

  double a = (r1*r1 - r2*r2 + d*d) / (2*d);
  double h = sqrt(max(r1*r1 - a*a, 0.0));
  P tmp1 = p1 + a / d * (p2-p1);
  P tmp2 = h / d * (p2-p1);

  if(abs(tmp2) < EPS) res.push_back(tmp1);
  else {
    res.push_back(P(real(tmp1) - imag(tmp2), imag(tmp1) + real(tmp2)));
    res.push_back(P(real(tmp1) + imag(tmp2), imag(tmp1) - real(tmp2)));
  }
  return res;
}



double len;
Rect rec;

// ?????????[0 ~ 2PI]????????´
double arg(P p){
  double res = atan2(imag(p), real(p));
  if(res < -EPS) res += 2.0 * M_PI;
  return res;
}

Rect move_up(Rect rec){
  Rect res = rec;
  P minp, maxp;

  while(imag(res.p[0]) < -EPS /*&& imag(res.p[2]) > -EPS*/){
    minp = rotate(res.p[0], M_PI / 2.0);
    maxp = rotate(res.p[2], M_PI / 2.0);
    res = Rect(real(minp), imag(minp), real(maxp), imag(maxp));
  }
  /*
  while(imag(res.p[0]) < -EPS && imag(res.p[2]) < -EPS){
    minp = rotate(res.p[0], M_PI);
    maxp = rotate(res.p[2], M_PI);
    res = Rect(real(minp), imag(minp), real(maxp), imag(maxp));
  }
  */
  //assert(imag(res.p[0]) > -EPS && imag(res.p[2]) > -EPS);
  
  return res;
}

int first_pp(int ii){
  int res = 0;
  for(int i=0;i<4;i++){
    P p = rec.p[res];
    P pi = rec.p[i];
    if(ii == 0 && (arg(p) < arg(pi) || equal(arg(p),arg(pi)) && abs(p) > abs(pi)) ||
       ii == 1 && (arg(p) > arg(pi) || equal(arg(p),arg(pi)) && abs(p) > abs(pi))){
      res = i;
    }
  }
  if(abs(rec.p[res]) > len + EPS) return -1;
  return res;
}

/*
Pint next_pp(Pint pp, int pos){
  map<Pint, Pint> mp;
  mp[Pint(0,0)] = Pint(1,0);
  mp[Pint(1,0)] = Pint(1,1);
  mp[Pint(1,1)] = Pint(0,1);
  mp[Pint(0,1)] = Pint(0,0);
  if(pos == 0) return mp[pp];
  else return mp[mp[mp[pp]]];
}
*/

void init_v(vector<Circle> v[2], P lastp[2]){
  for(int i=0;i<2;i++){
    int pp = first_pp(i), pp2;
    double rem_len = len;
    
    if(pp >= 0 && abs(rec.p[pp]) < rem_len - EPS){
      rem_len -= abs(rec.p[pp]);
      v[i].push_back(Circle(rec.p[pp], rem_len));

      for(int j=0;j<2;j++){
        pp2 = pp;
        if(i == 0) pp = (pp + 1) % 4;
        else pp = (pp + 3) % 4;
        if(j < 1 && abs(rec.p[pp] - rec.p[pp2]) < rem_len - EPS){
          rem_len -= abs(rec.p[pp] - rec.p[pp2]);
          v[i].push_back(Circle(rec.p[pp], rem_len));
        } else {
          lastp[i] = rec.p[pp];
          break;
        }
      }
    }
    /*
    if(abs(rec.p[0][i]) < len + EPS){
      v[i].push_back(Circle(rec.p[0][i], len - abs(rec.p[0][i])));
      if(v[i][0].r < abs(rec.p[0][i] - rec.p[1][i]) + EPS){
        v[i].push_back(Circle(rec.p[1][i], abs(rec.p[0][i] - rec.p[1][i]) - v[i][0].r));
      }
    }
    */
  }
}

P get_hit_point_10(Circle cir, bool is_01){
  int p = 0;
  P res = P(-1, -1);
  double res_arg = 0;
  if(!is_01) res_arg = 2.0 * M_PI;
  for(int i=0;i<4;i++) {
    int np = (p + 1) % 4;
    vector<P> pp = getIntersectCS(cir, L(rec.p[p], rec.p[np]));
    for(int j=0;j<pp.size();j++){
      if(is_01 && arg(pp[j]) > res_arg || !is_01 && arg(pp[j]) < res_arg) {
        res = pp[j];
        res_arg = arg(res);
      }
    }
    p = np;
  }
  return res;
}

double solve(int case_cnt){
  Circle cir = Circle(P(0,0), len);
  vector<Circle> v[2];
  P lastp[2];
  double ans = -1;
  
  rec = move_up(rec);
  init_v(v, lastp);

  if(v[0].size() == 0 && v[1].size() == 0) {
    P p1 = get_hit_point_10(cir, true);
    P p2 = get_hit_point_10(cir, false);
    if(imag(p1) < -0.9 || imag(p2) < -0.9) ans = cir.r * 2.0 * M_PI;
    else ans = cir.r * (2.0 * M_PI - (arg(p1) - arg(p2)));

  } else if(v[0].size() == 0){
    double prev_arg = arg(v[1][0].c);
    ans = cir.r * (2.0 * M_PI - (arg(get_hit_point_10(cir, true)) - arg(v[1][0].c)));
    for(int i=0;i<v[1].size();i++){      
      if(i == (int)v[1].size()-1){
        ans += v[1][i].r * (arg(lastp[1] - v[1][i].c) - prev_arg);
      } else {
        ans += v[1][i].r * (arg(v[1][i+1].c - v[1][i].c) - prev_arg);
        prev_arg = arg(v[1][i+1].c - v[1][i].c);
      }
    }

  } else if(v[1].size() == 0){
    double prev_arg = arg(v[0][0].c);
    ans = cir.r * (2.0 * M_PI - (arg(v[0][0].c) - arg(get_hit_point_10(cir, false))));
    for(int i=0;i<v[0].size();i++){      
      if(i == (int)v[0].size()-1){
        ans += v[0][i].r * (prev_arg - arg(lastp[0] - v[0][i].c));
      } else {
        ans += v[0][i].r * (prev_arg - arg(v[0][i+1].c - v[0][i].c));
        prev_arg = arg(v[0][i+1].c - v[0][i].c);
      }
    }

  } else {
    double sum = cir.r * (2.0*M_PI - (arg(v[0][0].c) - arg(v[1][0].c)));
    double prev_arg = arg(v[0][0].c), now_arg;
    double sum2_nothit = 0;
    if(equal(prev_arg, 0.0)) prev_arg = 2.0 * M_PI;
    ans = -1;
    for(int i=0;i<v[0].size();i++){
      double sum2 = 0;
      double prev_arg2 = arg(v[1][0].c), now_arg2;
      if(i < (int)v[0].size()-1) now_arg = arg(v[0][i+1].c - v[0][i].c);
      else now_arg = arg(lastp[0] - v[0][i].c);
      for(int j=0;j<v[1].size();j++){
        vector<P> vc = getIntersectCC(v[0][i], v[1][j]);
        if(j < (int)v[1].size()-1) now_arg2 = arg(v[1][j+1].c - v[1][j].c);
        else now_arg2 = arg(lastp[1] - v[1][j].c);
        for(int k=0;k<vc.size();k++){
          if(arg(vc[k]-v[0][i].c) >= now_arg - EPS && arg(vc[k]-v[0][i].c) <= prev_arg + EPS &&
             arg(vc[k]-v[1][j].c) >= prev_arg2 - EPS && arg(vc[k]-v[1][j].c) <= now_arg2 + EPS){
            ans = max(ans, sum + sum2 + v[0][i].r * (prev_arg - arg(vc[k]-v[0][i].c)) + v[1][j].r * (arg(vc[k]-v[1][j].c) - prev_arg2));
          }
        }
        //if(case_cnt == 26) cout << "> " << prev_arg2 * 180 / M_PI << ' ' << now_arg2 * 180 / M_PI << endl;
        sum2 += v[1][j].r * (now_arg2 - prev_arg2);
        prev_arg2 = now_arg2;
      }
      if(i == 0) sum2_nothit = sum2;
      //if(case_cnt == 26) cout << "> " << prev_arg * 180 / M_PI << ' ' << now_arg * 180 / M_PI << endl;
      sum += v[0][i].r * (prev_arg - now_arg);
      prev_arg = now_arg;
      if(equal(prev_arg, 0.0)) prev_arg = 2.0 * M_PI;
    }
    if(ans <= -EPS) ans = sum + sum2_nothit;
  }
  

  
  return ans;
}

int main(){
  int l, x, y, x2, y2, case_cnt = 1;
  while(cin >> l >> x >> y >> x2 >> y2 && (l|x|y|x2|y2)){
    len = l;
    rec = Rect(x, y, x2, y2);
    printf("%.8f\n",solve(case_cnt++));
  }
}

Measured memory_bytes: 1320