#include <bits/stdc++.h>
const int maxn = 102;
const double ee = 1e-8;
struct point {
  double x, y;
  point operator-(const point &p) const {
    point ans;
    ans.x = x - p.x;
    ans.y = y - p.y;
    return ans;
  }
  double xtimes(const point &p) const { return x * p.y - y * p.x; }
};
struct mark {
  bool outside;
  double t;
};
struct triangle {
  point p[3];
};
triangle tris[maxn];
double ts[maxn * 2];
bool cameraSolve(double a, double b, double c, double d, double e, double f,
                 double &t1, double &t2) {
  double det1, det2, det;
  det = a * d - b * c;
  if (det > -ee && det < ee) return false;
  det1 = e * d - b * f;
  det2 = a * f - e * c;
  t1 = det1 / det;
  t2 = det2 / det;
}
bool edgeCrossEdge(const point &p1, const point &p2, const point &p3,
                   const point &p4, double &t) {
  double t1, t2;
  if (!cameraSolve(p2.x - p1.x, p3.x - p4.x, p2.y - p1.y, p3.y - p4.y,
                   p3.x - p1.x, p3.y - p1.y, t1, t2))
    return false;
  if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
    t = t1;
    return true;
  }
  return false;
}
bool pointInTri(const point &p, const triangle &tri) {
  int k;
  for (k = 0; k < 3; k++) {
    const point &p0 = tri.p[k];
    const point &p1 = tri.p[(k + 1) % 3];
    const point &p2 = tri.p[(k + 2) % 3];
    point dp0, dp1, dp2;
    dp0 = p1 - p0;
    dp1 = p2 - p0;
    dp2 = p - p0;
    if (dp0.xtimes(dp1) * dp0.xtimes(dp2) < 0) return false;
  }
  return true;
}
int dblcmp(const void *a, const void *b) {
  double d = *(double *)a - *(double *)b;
  if (d > 0)
    return 1;
  else if (d < 0)
    return -1;
  else
    return 0;
}
double len(const point &p1, const point &p2) {
  double dx, dy;
  dx = p1.x - p2.x;
  dy = p1.y - p2.y;
  return sqrt(dx * dx + dy * dy);
}
double getAns(int n) {
  int i, j, k, k1, piece;
  double t;
  double total = 0;
  for (i = 0; i < n; i++) {
    for (k = 0; k < 3; k++) {
      const point &p1 = tris[i].p[k];
      const point &p2 = tris[i].p[(k + 1) % 3];
      int cnt;
      cnt = 0;
      ts[cnt++] = 0;
      for (j = 0; j < n; j++)
        if (j != i) {
          for (k1 = 0; k1 < 3; k1++) {
            const point &p3 = tris[j].p[k1];
            const point &p4 = tris[j].p[(k1 + 1) % 3];
            if (edgeCrossEdge(p1, p2, p3, p4, t)) {
              ts[cnt++] = t;
            }
          }
        }
      ts[cnt++] = 1;
      qsort(ts, cnt, sizeof(double), dblcmp);
      point pt1, pt2, pm;
      pt1.x = p1.x + (p2.x - p1.x) * ts[0];
      pt1.y = p1.y + (p2.y - p1.y) * ts[0];
      for (piece = 1; piece < cnt; piece++) {
        pt2.x = p1.x + (p2.x - p1.x) * ts[piece];
        pt2.y = p1.y + (p2.y - p1.y) * ts[piece];
        pm.x = (pt1.x + pt2.x) / 2;
        pm.y = (pt1.y + pt2.y) / 2;
        for (j = 0; j < n; j++) {
          if (j != i && pointInTri(pm, tris[j])) break;
        }
        if (j == n) {
          total += len(p1, p2) * (ts[piece] - ts[piece - 1]);
        }
        pt1 = pt2;
      }
    }
  }
  return total;
}
int main() {
  int n;
  int i, j;
  using std::cin;
  using std::cout;
  cin >> n;
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) cin >> tris[i].p[j].x >> tris[i].p[j].y;
  }
  cout.precision(10);
  cout.setf(std::ios_base::fixed);
  cout << getAns(n) << '\n';
  return 0;
}
