import java.io.*; import java.util.*; public class glaciertravel_mb { static final class Point { final int x, y; double normDX, normDY, length; Point(int x, int y) { this.x = x; this.y = y; } void linkTo(Point next) { double dx = next.x - x; double dy = next.y - y; this.length = Math.sqrt(dx * dx + dy * dy); this.normDX = dx / length; this.normDY = dy / length; } } private static Point fromLine(String line) { int ws = line.indexOf(' '); return new Point(Integer.parseInt(line.substring(0, ws)), Integer.parseInt(line.substring(ws + 1))); } private static void linkAll(Point[] points) { for (int i = 1; i < points.length; ++i) { points[i - 1].linkTo(points[i]); } } static final class Pointer { int index = 0; double time = 0; final Point[] points; Pointer(Point[] points) { this.points = points; } void advance(double change) { time += change; while (index + 1 < points.length) { double segmentLength = points[index].length; if (time < segmentLength - 1e-9) { break; } time -= segmentLength; ++index; } } double remainingTime() { return points[index].length - time; } double xt() { return points[index].normDX; } double yt() { return points[index].normDY; } double xc() { return points[index].normDX * time + points[index].x; } double yc() { return points[index].normDY * time + points[index].y; } } private static double solveOne(Pointer p1, Pointer p2) { double timeLeft = Math.min(p1.remainingTime(), p2.remainingTime()); double xt = p1.xt() - p2.xt(); double yt = p1.yt() - p2.yt(); double xc = p1.xc() - p2.xc(); double yc = p1.yc() - p2.yc(); double num = -(xt * xc + yt * yc); double den = xt * xt + yt * yt; double t; if (den < 1e-9) { t = timeLeft; } else { t = Math.min(timeLeft, Math.max(0, num / den)); } p1.advance(timeLeft); p2.advance(timeLeft); return Math.sqrt((xt * t + xc) * (xt * t + xc) + (yt * t + yc) * (yt * t + yc)); } private static double solve(Point[] points, double s) { int n = points.length - 1; Pointer first = new Pointer(points); Pointer second = new Pointer(points); first.advance(s); double result = Double.POSITIVE_INFINITY; while (first.index < n) { result = Math.min(result, solveOne(first, second)); } return result; } public static void main(String[] args) throws IOException { try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) { double s = Double.parseDouble(in.readLine()); int n = Integer.parseInt(in.readLine()); Point[] points = new Point[n]; for (int i = 0; i < n; ++i) { points[i] = fromLine(in.readLine()); } linkAll(points); System.out.println(solve(points, s)); } } }