#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  os << "{" << p.first << ", " << p.second << "}";
  return os;
}
const long double eps = 10E-8l;
struct Po {
  long double x, y;
  Po(long double _x = 0, long double _y = 0) : x(_x), y(_y) {}
};
Po operator+(const Po& a, const Po& b) { return Po(a.x + b.x, a.y + b.y); }
Po operator-(const Po& a, const Po& b) { return Po(a.x - b.x, a.y - b.y); }
Po operator*(const long double a, const Po& b) { return Po(a * b.x, a * b.y); }
Po operator/(const Po& b, const long double a) { return Po(b.x / a, b.y / a); }
bool operator<(const Po& a, const Po& b) {
  if (fabs(b.x - a.x) > eps) return a.x < b.x;
  return a.y < b.y;
}
long double norm(const Po& p) { return sqrt(p.x * p.x + p.y * p.y); }
ostream& operator<<(ostream& os, const Po& p) {
  os << make_pair(p.x, p.y);
  return os;
}
int n;
Po tr[128][3];
Po otr[512][2];
Po in[512];
long double cross(const Po& a, const Po& b) { return (a.x * b.y - a.y * b.x); }
bool inTriangle(const Po tr[3], const Po& p) {
  long double cr[3];
  for (int i = 0; i < 3; ++i)
    cr[i] = cross(tr[i] - tr[(i + 1) % 3], p - tr[(i + 1) % 3]);
  return ((cr[0] > eps && cr[1] > eps && cr[2] > eps) ||
          (cr[0] < -eps && cr[1] < -eps && cr[2] < -eps));
}
Po normal(const Po& p) { return p / norm(p); }
bool in_seg(const Po a[2], const Po& p) {
  return ((a[0].x < p.x && p.x < a[1].x) || (a[1].x < p.x && p.x < a[0].x)) ||
         (a[0].y < p.y && p.y < a[1].y) || (a[1].y < p.y && p.y < a[0].y);
}
bool intersect(const Po a[2], const Po b[2], Po& p, bool first = true) {
  Po da = a[1] - a[0];
  Po db = b[1] - b[0];
  if (norm(normal(da) - normal(db)) < eps ||
      norm(normal((-1) * da) - normal(db)) < eps)
    return false;
  if (da.x == 0.0l) {
    if (!first) {
      cout << make_pair(a[0], a[1]) << make_pair(b[0], b[1]) << endl;
      cout << make_pair(da, db) << endl;
      exit(0);
    }
    return intersect(b, a, p, false);
  }
  Po c = b[0] - a[0];
  Po aa = da;
  Po bb = (-1.0l) * db;
  long double u, t;
  u = (c.y - (aa.y * c.x) / aa.x) / (bb.y - (aa.y * bb.x) / aa.x);
  p = b[0] + u * db;
  return (in_seg(a, p) && in_seg(b, p));
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      long double xx, yy;
      cin >> xx >> yy;
      tr[i][j] = Po(xx, yy);
    }
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 2; ++k) otr[3 * i + j][k] = tr[i][(j + k) % 3];
  }
  long double len = 0.0l;
  for (int i = 0; i < 3 * n; ++i) {
    int cnt = 0;
    for (int k = 0; k < 2; ++k) in[cnt++] = otr[i][k];
    for (int j = 0; j < 3 * n; ++j) {
      if (i == j) continue;
      Po inter;
      if (intersect(otr[i], otr[j], inter)) {
        in[cnt++] = inter;
      }
    }
    sort(in, in + cnt);
    for (int j = 1; j < cnt; ++j) {
      Po p = (in[j - 1] + in[j]) / 2.0l;
      bool inTr = false;
      for (int k = 0; k < n; ++k) {
        if (inTriangle(tr[k], p)) {
          inTr = true;
          break;
        }
      }
      if (!inTr) len += norm(in[j - 1] - in[j]);
    }
  }
  cout.precision(10);
  cout << fixed << len << endl;
  return 0;
}
