import java.util.*;
import java.util.concurrent.*;

public class Euler264 {
    static long isqrt(long x) {
        if (x < 0)
            return 0;
        long r = (long) Math.sqrt(x);
        while ((r + 1) * (r + 1) <= x)
            r++;
        while (r * r > x)
            r--;
        return r;
    }

    static double dist(long ax, long ay, long bx, long by) {
        double dx = ax - bx;
        double dy = ay - by;
        return Math.sqrt(dx * dx + dy * dy);
    }

    static long gcd(long a, long b) {
        while (b != 0) {
            long t = b;
            b = a % b;
            a = t;
        }
        return Math.abs(a);
    }

    public static String solve() {
        int perimeterLimit = 100000;
        int threads = Math.max(1, Runtime.getRuntime().availableProcessors());

        double p = perimeterLimit;
        double rBound = (10.0 + Math.sqrt(100.0 + 12.0 * (25.0 + (p * p) / 9.0))) / 6.0;
        int rMax = (int) Math.floor(rBound);

        threads = Math.max(1, Math.min(threads, rMax + 2));

        int chunk = 32;
        List<int[]> tasks = new ArrayList<>();
        int startX = -rMax;
        while (startX <= 1) {
            int endX = Math.min(1, startX + chunk - 1);
            tasks.add(new int[] { startX, endX });
            startX += chunk;
        }

        double totalSum = 0.0;
        ExecutorService executor = Executors.newFixedThreadPool(threads);
        List<Future<Double>> futures = new ArrayList<>();

        for (int[] task : tasks) {
            final int xStart = task[0];
            final int xEnd = task[1];

            futures.add(executor.submit(() -> {
                double localSum = 0.0;
                for (int cx = xStart; cx <= xEnd; ++cx) {
                    long cx2 = (long) cx * cx;
                    long cyMax = isqrt((long) rMax * rMax - cx2);

                    for (long cy = -cyMax; cy <= cyMax; ++cy) {
                        long r2 = cx2 + cy * cy;
                        if (r2 == 0)
                            continue;

                        long sx = 5 - cx;
                        long sy = -cy;
                        long den = sx * sx + sy * sy;
                        if (den == 0)
                            continue;

                        long d = 4 * r2 - den;
                        if (d <= 0)
                            continue;

                        long g = gcd(Math.abs(sx), Math.abs(sy));
                        long num = d * g * g;
                        if (num % den != 0)
                            continue;

                        long t2 = num / den;
                        long tt = isqrt(t2);
                        if (tt * tt != t2)
                            continue;

                        long px = -sy / g;
                        long py = sx / g;
                        long ux = tt * px;
                        long uy = tt * py;

                        if (((sx + ux) & 1) != 0 || ((sy + uy) & 1) != 0)
                            continue;

                        long ax = (sx + ux) / 2;
                        long ay = (sy + uy) / 2;
                        long bx = (sx - ux) / 2;
                        long by = (sy - uy) / 2;

                        if ((ax == bx && ay == by) || (ax == cx && ay == cy) || (bx == cx && by == cy))
                            continue;

                        if (!(cx < ax || (cx == ax && cy <= ay)))
                            continue;
                        if (!(cx < bx || (cx == bx && cy <= by)))
                            continue;

                        if (ax * ax + ay * ay != r2 || bx * bx + by * by != r2)
                            continue;
                        if (ax + bx + cx != 5 || ay + by + cy != 0)
                            continue;

                        long area2 = Math.abs((bx - ax) * (cy - ay) - (by - ay) * (cx - ax));
                        if (area2 == 0)
                            continue;

                        double perimeter = dist(ax, ay, bx, by) + dist(ax, ay, cx, cy) + dist(bx, by, cx, cy);
                        if (perimeter > perimeterLimit + 1e-12)
                            continue;

                        localSum += perimeter;
                    }
                }
                return localSum;
            }));
        }

        for (Future<Double> f : futures) {
            try {
                totalSum += f.get();
            } catch (Exception e) {
            }
        }
        executor.shutdown();

        double roundTotal = Math.round(totalSum * 10000.0) / 10000.0;
        return String.format(Locale.US, "%.4f", roundTotal);
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
