#include <bits/stdc++.h>   using namespace std;   const int MaxN = 110;   const double EPS = 1E-10;   struct TTriangle {     double x[3], y[3];   } a[MaxN];   struct TSeg {     double x[2], y[2];   } Seg[MaxN * 3];   int n, Total;   double Ans;   pair<double, int> s[MaxN * 3 * 2];   inline double Cross(const double x1, const double y1, const double x2,                       const double y2) {     return x1 * y2 - x2 * y1;   }   inline bool Equal(const TTriangle &a, const TTriangle &b) {     return a.x[0] == b.x[0] && a.y[0] == b.y[0] && a.x[1] == b.x[1] &&                a.y[1] == b.y[1] && a.x[2] == b.x[2] && a.y[2] == b.y[2] ||            a.x[0] == b.x[1] && a.y[0] == b.y[1] && a.x[1] == b.x[2] &&                a.y[1] == b.y[2] && a.x[2] == b.x[0] && a.y[2] == b.y[0] ||            a.x[0] == b.x[2] && a.y[0] == b.y[2] && a.x[1] == b.x[0] &&                a.y[1] == b.y[0] && a.x[2] == b.x[1] && a.y[2] == b.y[1];   }   void Init() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %lf%lf%lf%lf%lf%lf , &a[i].x[0], &a[i].y[0], &a[i].x[1], &a[i].y[1],             &a[i].x[2], &a[i].y[2]);       if (Cross(a[i].x[1] - a[i].x[0], a[i].y[1] - a[i].y[0],                 a[i].x[2] - a[i].x[0], a[i].y[2] - a[i].y[0]) < -EPS) {         swap(a[i].x[1], a[i].x[2]);         swap(a[i].y[1], a[i].y[2]);       }       for (int j = 1; j < i; ++j)         if (Equal(a[i], a[j])) {           --i, --n;           break;         }     }     for (int i = 1; i <= n; ++i) {       Seg[i * 3 - 2].x[0] = a[i].x[0], Seg[i * 3 - 2].y[0] = a[i].y[0],                   Seg[i * 3 - 2].x[1] = a[i].x[1],                   Seg[i * 3 - 2].y[1] = a[i].y[1];       Seg[i * 3 - 1].x[0] = a[i].x[1], Seg[i * 3 - 1].y[0] = a[i].y[1],                   Seg[i * 3 - 1].x[1] = a[i].x[2],                   Seg[i * 3 - 1].y[1] = a[i].y[2];       Seg[i * 3].x[0] = a[i].x[2], Seg[i * 3].y[0] = a[i].y[2],               Seg[i * 3].x[1] = a[i].x[0], Seg[i * 3].y[1] = a[i].y[0];     }   }   inline bool Check(const TSeg &a, const TSeg &b) {     return Cross(b.x[0] - a.x[0], b.y[0] - a.y[0], b.x[1] - a.x[0],                  b.y[1] - a.y[0]) *                Cross(b.x[0] - a.x[1], b.y[0] - a.y[1], b.x[1] - a.x[1],                      b.y[1] - a.y[1]) <            EPS;   }   inline double GetRatio(const TSeg &a, const TSeg &b) {     const double u = Cross(a.x[1] - a.x[0], a.y[1] - a.y[0], b.x[0] - a.x[0],                            b.y[0] - a.y[0]),                  v = u + Cross(b.x[1] - a.x[0], b.y[1] - a.y[0], a.x[1] - a.x[0],                                a.y[1] - a.y[0]);     return u / v;   }   inline void Calc(const TSeg &a, const TSeg &b, const TSeg &c) {     if (Check(a, c) && Check(b, c)) {       double l = GetRatio(a, c), r = GetRatio(b, c);       if (l > r) swap(l, r);       l = (l > (double)0 ? l : (double)0);       l = (l < (double)1 ? l : (double)1);       r = (r > (double)0 ? r : (double)0);       r = (r < (double)1 ? r : (double)1);       if (fabs(l - r) < EPS) return;       s[++Total] = make_pair(l, -1);       s[++Total] = make_pair(r, 1);     }   }   inline pair<double, double> RatioToVertex(const TSeg &a, const double &k) {     return make_pair(a.x[0] + (a.x[1] - a.x[0]) * k,                      a.y[0] + (a.y[1] - a.y[0]) * k);   }   int main() {     Init();     double l;     pair<double, double> p1, p2;     for (int i = 1, j, k; i <= n * 3; ++i) {       for (j = 1, Total = 0; j <= n; ++j)         if ((i - 1) / 3 + 1 != j) {           Calc(Seg[j * 3 - 2], Seg[j * 3 - 1], Seg[i]);           Calc(Seg[j * 3 - 1], Seg[j * 3], Seg[i]);           Calc(Seg[j * 3], Seg[j * 3 - 2], Seg[i]);         }       sort(s + 1, s + Total + 1);       s[++Total] = make_pair((double)1, 0);       for (j = 1, k = 0; j <= Total; ++j) {         if (!k) {           p1 = RatioToVertex(Seg[i], s[j - 1].first);           p2 = RatioToVertex(Seg[i], s[j].first);           Ans += sqrt(((p1.first - p2.first) * (p1.first - p2.first)) +                       ((p1.second - p2.second) * (p1.second - p2.second)));         }         k -= s[j].second;       }     }     cout << setprecision(10) << fixed << Ans << endl;     return 0;   }