#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

#define double long double
typedef complex<double> P;
P pIN() { double x,y; cin >> x >> y; return P(x,y); }
namespace std {
  bool operator < (const P& a, const P& b) {
    // if (abs(a-b)<EPS) return 0;
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() {}
  void in() {
    clear();
    push_back(pIN());
    push_back(pIN());
  }
  P v() const { return (*this)[1]-(*this)[0]; }
};
ostream &operator<<(ostream &os, const L &a) {
  os << a[0] << " -> " << a[1];
  return os;
}

typedef vector<P> G;
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(L l, P p) {
  P b = l.v(), c = p-l[0];
  if (cross(b, c) > EPS)   return +1;       // counter clockwise
  if (cross(b, c) < -EPS)   return -1;       // clockwise
  if (dot(b, c) < -EPS)     return +2;       // c--a--b on line
  if (EPS < norm(b) && norm(b) < norm(c)-EPS) return -2;  // a--b--c on line
  return 0;                               // a=c | b=c | a--c--b
}

int ccw(L l, L m) { return ccw(l,l[0]+m.v()); }
int ccw2(L l, P p) { return abs(ccw(l,p)) == 1 ? ccw(l,p) : 0; }
int ccw2(L l, L m) { return ccw2(l,l[0]+m.v()); }

// notice l[0] == l[1]
bool online(L l, P p) { return !ccw2(l,p); }
bool onseg2(L s, P p) { return ccw(L(s[0],p),s[1]) == -2; }
bool sameline(L l, L m) { return !ccw2(l,m[0]) && !ccw2(l,m[1]); }
bool parallel(L l, L m) { return !ccw2(l,m); }
bool different(L l, L s) { return ccw2(l,s[0])*ccw2(l,s[1]) <= 0; }
bool different2(L l, L s) { return ccw(l,s[0])*ccw(l,s[1]) == -1; }

bool intersectLL(L l, L m) { return !parallel(l,m) || sameline(l,m); }
bool intersectLS(L l, L s) { return different(l,s); }
bool intersectLS2(L l, L s) { return different2(l,s) || sameline(l,s); }
bool intersectSS(L s, L t) { return different(s,t) && different(t,s); }
bool intersectSS2(L s, L t) {  // AOJ265,1171,2029
  if (sameline(s,t)) return onseg2(s,t[0]) || onseg2(s,t[1]);
  else return different2(s,t) && different2(t,s);
}
bool intersectSP(L l, P p) { return ccw(l,p)==0; }

bool intersectLH(L l, L h) {
  if (intersectLS(l,h) || online(l,h[0])) return 1;
  if (parallel(l,h)) return 0;  
  return (ccw(l,h[0]) == 1) ^ (ccw(l,h) == 1);
}
bool intersectHS(L h, L s) {
  if (intersectSS(h,s)) return 1;
  if (!intersectLS(h,s)) return 0;
  if (sameline(h,s)) return ccw(h,s[0]) != 2 || ccw(h,s[1]) != 2;
  return (ccw(s,h[0]) == 1) ^ (ccw(s,h) == 1);
}
bool intersectHH(L h, L k) {
  if (sameline(h,k)) return intersectHS(h,k) || intersectHS(k,h);
  return intersectLH(h,k) && intersectLH(k,h);
}

P projection(L l, P p) { return l[0] + dot(p-l[0], l.v()) / norm(l.v()) * l.v(); }
P reflection(L l, P p) { return p + P(2,0)*(projection(l, p) - p); }
double distanceLP(L l, P p) { return abs(p - projection(l, p)); }
double distanceLL(L l, L m) { return intersectLL(l, m) ? 0 : distanceLP(l, m[0]); }
double distanceLS(L l, L s) { return intersectLS(l, s) ? 0 : min(distanceLP(l,s[0]), distanceLP(l,s[1])); }
double distanceSP(L s, P p) {
  const P r = projection(s, p);
  return intersectSP(s,r) ? abs(r-p) : min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(L s, L t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l.v(), m.v());
  double B = cross(l.v(), l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * m.v();
}
double angle(const P &a, const P &b) {        // テ」ツδ凖」ツつッテ」ツδ暗」ツδォテッツスツ?」ツ?凝」ツつ嘉」ツ?ソテ」ツ?淌」ツδ凖」ツつッテ」ツδ暗」ツδォテッツスツづ」ツ?ョティツァツ津・ツコツヲテ」ツ?ョティツィツ暗ァツョツ夕0,2pi)
  double ret = arg(b)-arg(a);
  return (ret>=0) ? ret : ret + 2*PI;
}


L l[40000];
double r[40000];
double upper[40000][2];
double len[40000];
double clen[40000];

int main() {
  int n,A;
  while(cin >> n >> A) {
    REP(i,n) {
      l[i].in();
      len[i] = abs(l[i].v());
    }
    REP(i,n-1) {
      L l1 = L(l[i][1],l[i][1]+l[i].v()*P(0,1));
      L l2 = L(l[i+1][0], l[i+1][0]+l[i+1].v()*P(0,1));
      assert(intersectLL(l1,l2));
      P cp;
      if (sameline(l1,l2)) cp = P(0.5,0)*(l1[0]+l2[0]);
      else cp = crosspoint(l1,l2);
      r[i] = abs(l1[0]-cp);
      assert(abs(abs(l2[0]-cp)-r[i]) < EPS);
      double theta;
      if (ccw(l[i],cp) == 1) theta = angle(l1[0]-cp,l2[0]-cp);
      else theta = angle(l2[0]-cp,l1[0]-cp);
      clen[i] = r[i]*theta;
    }
    for (int i=n-1; i>=0;--i) {
      if (i<n-1) upper[i][1] = upper[i+1][0];
      else upper[i][1] = 0;
      upper[i][0] = sqrt(upper[i][1]*upper[i][1] + 2 * A * len[i]+EPS);
      if (i) chmin(upper[i][0], sqrt(r[i-1]*A));
    }
    double nowv = 0;
    double res = 0;
    REP(i,n) {
      double d = len[i]/2 + (upper[i][1]*upper[i][1] - nowv*nowv) / (4*A);
      assert(d+EPS >= 0);
      if (d > len[i]) {
        double tv = sqrt(nowv * nowv + 2 * A * len[i] + EPS);
        res += (tv - nowv) / A;
        nowv = tv;
      } else {
        double D = sqrt(nowv * nowv + 2 * A * d + EPS);
        res += ( -nowv + D ) / A;
        res += ( -upper[i][1] + D ) / A;
        nowv = upper[i][1];
      }
      // cout << upper[i][0] << " " << upper[i][1] << endl;
      // cout << nowv << endl;
      // cout << "time = " << res << endl;
      if (i<n-1) {
        res += clen[i] / nowv;
      }
    }
    printf("%.10Lf\n", res);
  }
}

Measured memory_bytes: 8472