#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-6;
struct pt {
  double x, y;
  pt() {}
  pt(double _x, double _y) : x(_x), y(_y) {}
};
inline bool operator<(pt a, pt b) {
  return make_pair(a.x, a.y) < make_pair(b.x, b.y);
}
struct line {
  double a, b, c;
  line(double _a, double _b, double _c) : a(_a), b(_b), c(_c) {}
};
struct vecd {
  double x, y;
  vecd(double _x, double _y) : x(_x), y(_y) {}
  double norm() { return sqrt(x * x + y * y); }
};
inline vecd operator/(vecd w, double x) { return vecd(w.x / x, w.y / x); }
inline pt operator-(pt a, vecd w) { return pt(a.x - w.x, a.y - w.y); }
inline pt operator+(pt a, vecd w) { return pt(a.x + w.x, a.y + w.y); }
inline pt operator+(pt a, pt b) { return pt(a.x + b.x, a.y + b.y); }
inline pt operator/(pt a, double x) { return pt(a.x / x, a.y / x); }
struct seg {
  pt a, b;
  line toLine() { return line(a.y - b.y, b.x - a.x, a.x * b.y - b.x * a.y); }
  vecd toVec() { return vecd(a.y - b.y, b.x - a.x); }
  seg(pt _a, pt _b) : a(_a), b(_b) {}
  bool isin(pt w) {
    return (min(a.x, b.x) - EPS < w.x && w.x < max(a.x, b.x) + EPS) ||
           (min(a.y, b.y) - EPS < w.y && w.y < max(a.y, b.y) + EPS);
  }
};
double det(double a, double b, double c, double d) { return a * d - b * c; }
inline bool intersect(line m, line n, pt& res) {
  double zn = det(m.a, m.b, n.a, n.b);
  if (abs(zn) < EPS) return false;
  res.x = -det(m.c, m.b, n.c, n.b) / zn;
  res.y = -det(m.a, m.c, n.a, n.c) / zn;
  return true;
}
inline bool iseg(seg a, seg b, pt& res) {
  if (!intersect(a.toLine(), b.toLine(), res)) return false;
  if (a.isin(res) && b.isin(res)) return true;
  return false;
}
inline double S(pt a, pt b) { return (a.x - b.x) * (a.y + b.y) / 2.0; }
inline double S(pt a, pt b, pt c) { return S(a, b) + S(b, c) + S(c, a); }
struct triangle {
  pt a[3];
  vector<pt> div[3];
  bool isin(pt w) {
    double e, r, t;
    e = S(a[0], a[1], w), r = S(a[1], a[2], w), t = S(a[2], a[0], w);
    if (e > -EPS && r > -EPS && t > -EPS) return true;
    if (e < EPS && r < EPS && t < EPS) return true;
    return false;
  }
};
vector<triangle> t;
inline bool col(pt a) {
  bool c = false;
  for (int _n(((int)((t).end() - (t).begin())) - 1), i(0); i <= _n; i++)
    c |= t[i].isin(a);
  return c;
}
int main() {
  int n;
  scanf("%d", &n);
  t.resize(n);
  for (int _n((n)-1), i(0); i <= _n; i++) {
    int x1, y1, x2, y2, x3, y3;
    scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3);
    t[i].a[0].x = x1;
    t[i].a[0].y = y1;
    t[i].a[1].x = x2;
    t[i].a[1].y = y2;
    t[i].a[2].x = x3;
    t[i].a[2].y = y3;
  }
  for (int _n((n)-1), i(0); i <= _n; i++)
    for (int _n((n)-1), j(0); j <= _n; j++) {
      pt ir;
      for (int _n((3) - 1), k(0); k <= _n; k++)
        for (int _n((3) - 1), u(0); u <= _n; u++) {
          if (iseg(seg(t[i].a[k], t[i].a[(k + 1) % 3]),
                   seg(t[j].a[u], t[j].a[(u + 1) % 3]), ir)) {
            t[i].div[k].push_back(ir);
            t[j].div[u].push_back(ir);
          }
        }
    }
  double res = 0;
  for (int _n((n)-1), i(0); i <= _n; i++)
    for (int _n((3) - 1), k(0); k <= _n; k++)
      t[i].div[k].push_back(t[i].a[k]),
          t[i].div[k].push_back(t[i].a[(k + 1) % 3]);
  for (int _n((n)-1), i(0); i <= _n; i++)
    for (int _n((3) - 1), k(0); k <= _n; k++)
      sort((t[i].div[k]).begin(), (t[i].div[k]).end());
  for (int _n((n)-1), i(0); i <= _n; i++)
    for (int _n((3) - 1), k(0); k <= _n; k++)
      for (int _n(((int)((t[i].div[k]).end() - (t[i].div[k]).begin()) - 1) - 1),
           j(0);
           j <= _n; j++) {
        pt md = (t[i].div[k][j] + t[i].div[k][j + 1]) / 2.0;
        seg s = seg(t[i].div[k][j], t[i].div[k][j + 1]);
        vecd v = s.toVec();
        v = v / (v.norm() * 100.0);
        double l = sqrt((s.a.x - s.b.x) * (s.a.x - s.b.x) +
                        (s.a.y - s.b.y) * (s.a.y - s.b.y));
        if (l < EPS) continue;
        if (col(md + v) ^ col(md - v)) res += l;
      }
  printf("%.9lf\n", res);
  return 0;
}
