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

public class greatwall_mb {
    private static class Segment {
        private final int x1, y1, x2, y2;
        public Segment(int x1, int y1, int x2, int y2) {
            if (x1 > x2 || x1 == x2 && y1 > y2) {
                this.x1 = x2;
                this.y1 = y2;
                this.x2 = x1;
                this.y2 = y1;
            } else {
                this.x1 = x1;
                this.y1 = y1;
                this.x2 = x2;
                this.y2 = y2;
            }
        }
        public int hashCode() {
            int rv = 117;
            rv = 31 * rv + x1;
            rv = 31 * rv + y1;
            rv = 31 * rv + x2;
            rv = 31 * rv + y2;
            return rv;
        }
        public boolean equals(Object o) {
            if (o instanceof Segment) {
                Segment s = (Segment) o;
                return x1 == s.x1 && y1 == s.y1 && x2 == s.x2 && y2 == s.y2;
            } else {
                return false;
            }
        }
    }

    private static void myAssert(String msg, boolean exp) {
        if (!exp) {
            throw new AssertionError(msg);
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader("greatwall.in"));
        int m = Integer.parseInt(in.readLine());
        myAssert("m is out of bounds", 1 <= m && m <= 1000);
        Set<Segment> set = new HashSet<Segment>();
        int[] x = new int[3];
        int[] y = new int[3];
        for (int line = 0; line < m; ++line) {
            StringTokenizer st = new StringTokenizer(in.readLine());
            myAssert("Line #" + (line + 2) + " is incorrectly formatted", st.countTokens() == 6);
            for (int i = 0; i < 3; ++i) {
                x[i] = Integer.parseInt(st.nextToken());
                y[i] = Integer.parseInt(st.nextToken());
                myAssert("x is out of bounds", -10000 <= x[i] && x[i] <= 10000);
                myAssert("y is out of bounds", -10000 <= y[i] && y[i] <= 10000);
            }
            for (int i = 0; i < 3; ++i) {
                int j = (i + 1) % 3;
                Segment s = new Segment(x[i], y[i], x[j], y[j]);
                if (set.contains(s)) {
                    set.remove(s);
                } else {
                    set.add(s);
                }
            }
        }
        double answer = 0;
        for (Segment s : set) {
            int dx = s.x1 - s.x2;
            int dy = s.y1 - s.y2;
            answer += Math.sqrt(dx * dx + dy * dy);
        }
        PrintWriter out = new PrintWriter("greatwall.out");
        out.println(answer);
        out.close();
    }
}
