#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
double sqr(double x) { return x * x; }
int sgn(double x) {
  if (x < -eps) return -1;
  if (x > eps) return 1;
  return 0;
}
struct point {
  double x, y;
  point(double _x = 0, double _y = 0) { x = _x, y = _y; }
  point operator+(const point &a) { return point(x + a.x, y + a.y); }
  point operator*(const double &a) { return point(x * a, y * a); }
  friend bool operator<(const point &a, const point &b) {
    if (a.x == b.x) return a.y < b.y;
    return a.x < b.x;
  }
  void input() { scanf("%lf%lf", &x, &y); }
} p[105][8], e[800];
double dist(point a, point b) { return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y)); }
int mult(point a, point b, point c) {
  return sgn((a.x - c.x) * (b.y - c.y) - (a.y - c.y) * (b.x - c.x));
}
bool inter(point a, point b, point c, point d) {
  if (min(a.x, b.x) > max(c.x, d.x) || min(a.y, b.y) > max(c.y, d.y) ||
      min(c.x, d.x) > max(a.x, b.x) || min(c.y, d.y) > max(a.y, b.y))
    return 0;
  double h, i, j, k;
  h = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
  i = (b.x - a.x) * (d.y - a.y) - (b.y - a.y) * (d.x - a.x);
  j = (d.x - c.x) * (a.y - c.y) - (d.y - c.y) * (a.x - c.x);
  k = (d.x - c.x) * (b.y - c.y) - (d.y - c.y) * (b.x - c.x);
  return h * i <= eps && j * k <= eps;
}
point intersection(point u1, point u2, point v1, point v2) {
  point ret = u1;
  double t = ((u1.x - v1.x) * (v1.y - v2.y) - (u1.y - v1.y) * (v1.x - v2.x)) /
             ((u1.x - u2.x) * (v1.y - v2.y) - (u1.y - u2.y) * (v1.x - v2.x));
  ret.x += (u2.x - u1.x) * t;
  ret.y += (u2.y - u1.y) * t;
  return ret;
}
int parallel(point u1, point u2, point v1, point v2) {
  double d = (u1.y - u2.y) * (v1.x - v2.x) - (v1.y - v2.y) * (u1.x - u2.x);
  return sgn(d) == 0;
}
bool isin(point t, int n, point p[]) {
  for (int i = 0; i < n; i++) {
    if (mult(t, p[i + 1], p[i]) * mult(t, p[i + 2], p[i + 1]) < 0) return 0;
  }
  return 1;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) p[i][j].input();
      p[i][3] = p[i][0];
      p[i][4] = p[i][1];
    }
    double ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) {
        int m = 0;
        e[m++] = p[i][j];
        e[m++] = p[i][j + 1];
        for (int k = 0; k < n; k++) {
          if (k == i) continue;
          for (int l = 0; l < 3; l++) {
            if (!inter(p[i][j], p[i][j + 1], p[k][l], p[k][l + 1]) ||
                parallel(p[i][j], p[i][j + 1], p[k][l], p[k][l + 1]))
              continue;
            e[m++] = intersection(p[i][j], p[i][j + 1], p[k][l], p[k][l + 1]);
          }
        }
        sort(e, e + m);
        for (int k = 0; k < m - 1; k++) {
          point t = (e[k] + e[k + 1]) * 0.5;
          bool f = 1;
          for (int l = 0; l < n; l++) {
            if (l == i) continue;
            if (isin(t, 3, p[l])) f = 0;
          }
          if (f) ans += dist(e[k], e[k + 1]);
        }
      }
    }
    printf("%.10f\n", ans);
  }
}
