#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-8;
int dcmp(long double x) {
  if (abs(x) < eps)
    return 0;
  else
    return x < 0 ? -1 : 1;
}
struct Pt {
  long double x, y;
  Pt(long double _x = 0, long double _y = 0) : x(_x), y(_y) {}
  Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
  Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
  Pt operator*(const long double &a) const { return Pt(x * a, y * a); }
  Pt operator/(const long double &a) const { return Pt(x / a, y / a); }
  long double operator*(const Pt &a) const { return x * a.x + y * a.y; }
  long double operator^(const Pt &a) const { return x * a.y - y * a.x; }
  bool operator<(const Pt &a) const { return x < a.x || (x == a.x && y < a.y); }
  bool operator==(const Pt &a) const {
    return dcmp(x - a.x) == 0 && dcmp(y - a.y) == 0;
  }
};
long double norm2(const Pt &a) { return a * a; }
long double norm(const Pt &a) { return sqrt(norm2(a)); }
Pt perp(const Pt &a) { return Pt(-a.y, a.x); }
Pt rotate(const Pt &a, long double ang) {
  return Pt(a.x * cos(ang) - a.y * sin(ang), a.x * sin(ang) + a.y * cos(ang));
}
struct Line {
  Pt s, e, v;
  long double ang;
  Line(Pt _s = Pt(0, 0), Pt _e = Pt(0, 0)) : s(_s), e(_e) {
    v = e - s;
    ang = atan2(v.y, v.x);
  }
  bool operator<(const Line &L) const { return ang < L.ang; }
};
struct Circle {
  Pt o;
  long double r;
  Circle(Pt _o = Pt(0, 0), long double _r = 0) : o(_o), r(_r) {}
};
bool onseg(Pt p, Line L) {
  Pt x = L.s - p, y = L.e - p;
  return dcmp(x ^ y) == 0 && dcmp(x * y) <= 0;
}
int inPoly(Pt p, vector<Pt> &v) {
  int n = v.size(), wn = 0;
  for (int i = 0; i < n; ++i) {
    if (onseg(p, Line(v[i], v[(i + 1) % n]))) return -1;
    int k = dcmp((v[(i + 1) % n] - v[i]) ^ (p - v[i]));
    int d1 = dcmp(v[i].y - p.y), d2 = dcmp(v[(i + 1) % n].y - p.y);
    if (k > 0 && d1 <= 0 && d2 > 0) ++wn;
    if (k < 0 && d2 <= 0 && d1 > 0) --wn;
  }
  if (wn != 0) return 1;
  return 0;
}
Pt LLIntersect(Line a, Line b) {
  Pt p1 = a.s, p2 = a.e, q1 = b.s, q2 = b.e;
  double f1 = (p2 - p1) ^ (q1 - p1), f2 = (p2 - p1) ^ (p1 - q2), f = f1 + f2;
  if (dcmp(f) == 0) return dcmp(f1) ? Pt(NAN, NAN) : Pt(INFINITY, INFINITY);
  return q1 * (f2 / f) + q2 * (f1 / f);
}
Pt SSIntersect(Line a, Line b) {
  Pt p = LLIntersect(a, b);
  if (isinf(p.x) &&
      (onseg(a.s, b) || onseg(a.e, b) || onseg(b.s, a) || onseg(b.e, a)))
    return p;
  if (isfinite(p.x) && onseg(p, a) && onseg(p, b)) return p;
  return {NAN, NAN};
}
int n;
vector<vector<Pt> > v;
vector<Line> seg, seg2;
vector<Pt> inter[100000];
long double check(int id) {
  Pt mid = (seg2[id].s + seg2[id].e) / 2;
  for (int i = 0; i < n; ++i)
    if (inPoly(mid, v[i]) == 1) return 0.0;
  return norm(seg2[id].v);
}
void init() {
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      Pt p;
      cin >> p.x >> p.y;
      v[i].push_back(p);
    }
  }
}
void solve() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      seg.push_back(Line(v[i][j], v[i][(j + 1) % 3]));
    }
  }
  for (int i = 0; i < 3 * n; ++i) {
    inter[i].push_back(seg[i].s);
    inter[i].push_back(seg[i].e);
    for (int j = i + 1; j < 3 * n; ++j)
      if (i / 3 != j / 3) {
        Pt p = SSIntersect(seg[i], seg[j]);
        if (!isnan(p.x) && !isinf(p.x)) {
          inter[i].push_back(p);
          inter[j].push_back(p);
        }
      }
    sort(inter[i].begin(), inter[i].end());
    for (int j = 0; j < (int)inter[i].size() - 1; ++j) {
      seg2.push_back(Line(inter[i][j], inter[i][j + 1]));
    }
  }
  long double ans = 0;
  for (int i = 0; i < (int)seg2.size(); ++i) {
    ans += check(i);
  }
  cout << fixed << setprecision(10) << ans << '\n';
}
int main() {
  init();
  solve();
}
