#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;
}

// ?????? miny >= 0 ???????????????????????¢??????
Rect move_up(Rect rec){
  Rect res = rec;
  P minp, maxp;

  while(imag(res.p[0]) < -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));
  }
  
  return res;
}

// init_v??§?????¨
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;
}

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;
        }
      }
    }
  }
}

// ????§???¢???????????´???????????´???
P get_side_hit_point(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(){
  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_side_hit_point(cir, true);
    P p2 = get_side_hit_point(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_side_hit_point(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_side_hit_point(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));
          }
        }
        sum2 += v[1][j].r * (now_arg2 - prev_arg2);
        prev_arg2 = now_arg2;
      }
      if(i == 0) sum2_nothit = sum2;
      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;
  while(cin >> l >> x >> y >> x2 >> y2 && (l|x|y|x2|y2)){
    len = l;
    rec = Rect(x, y, x2, y2);
    printf("%.8f\n",solve());
  }
}

Measured memory_bytes: 1320