import java.io.*;
import java.util.*;
import java.math.*;

public class football_aa_norm implements Runnable {

	public static void main(String[] args) {
		new Thread(new football_aa_norm()).start();
	}

	public void run() {
		try {
			solve();
		} catch (IOException e) {
		}
	}

	private void MyAssert(boolean u, String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	BufferedReader br;

	StringTokenizer st;

	PrintWriter out;

	boolean eof = false;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	String nextToken(String delim) {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine(), delim);
			} catch (IOException e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken(delim);
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	int nextInt(String delim) {
		return Integer.parseInt(nextToken(delim));
	}

	String FILENAME = "football";

	void solve() throws IOException {
		br = new BufferedReader(new FileReader(FILENAME + ".in"));
		out = new PrintWriter(FILENAME + ".out");
		int n = nextInt();
		long r = nextInt();
		long t1 = 0;
		long x1 = 0;
		long y1 = 0;
		long cx1 = 0;
		long cy1 = 0;
		long t2 = nextInt();
		long x2 = nextInt();
		long y2 = nextInt();
		long cx2 = nextInt();
		long cy2 = nextInt();
		double ans = 0;
		for (int i = 1; i < n; i++) {
			t1 = t2;
			x1 = x2;
			y1 = y2;
			cx1 = cx2;
			cy1 = cy2;
			t2 = nextInt();
			x2 = nextInt();
			y2 = nextInt();
			cx2 = nextInt();
			cy2 = nextInt();
			double[] t = solve(x1, y1, x2, y2, cx1, cy1, cx2, cy2, r);
			if (t.length < 2) {
				continue;
			}
			t[0] = Math.max(t[0], 0);
			t[1] = Math.min(t[1], 1);
			if (t[1] > t[0]) {
				ans += (t[1] - t[0]) * (t2 - t1);
			}
		}
		out.println(ans);
		out.close();
	}

	private double[] solve(long x1, long y1, long x2, long y2, long cx1,
			long cy1, long cx2, long cy2, long r) {
		double dx = x2 - x1;
		double dy = y2 - y1;
		double dcx = cx2 - cx1;
		double dcy = cy2 - cy1;
		double a = x1 - cx1;
		double b = dcx - dx;
		double c = y1 - cy1;
		double d = dcy - dy;
		double aa = b * b + d * d;
		double bb = -a * b - c * d;
		double cc = a * a + c * c - r * r;
		double dd = bb * bb - aa * cc;
		double eps = 1e-8;
		if (Math.abs(aa) < eps) {
			if (Math.abs(bb) < eps) {
				if (cc < eps) {
					return new double[] { 0.0, 1.0 };
				}
			}
			return new double[] {};
		}
		if (dd < eps) {
			return new double[0];
		}
		if (Math.abs(dd) < eps) {
			return new double[] { (0.0 - bb) / aa };
		}
		return new double[] { (0.0 - bb - Math.sqrt(dd)) / aa,
				(0.0 - bb + Math.sqrt(dd)) / aa };
	}
}
