#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:136777216")
using namespace std;
int bits(int x) { return x == 0 ? 0 : 1 + bits(x & (x - 1)); }
const long double PI = 3.14159265358979323846;
const long double eps = 1e-12;
struct pt {
  long double x, y;
  pt() {}
  pt(long double xx, long double yy) { x = xx, y = yy; }
};
struct triangle {
  pt A, B, C;
  triangle() {}
  triangle(pt AA, pt BB, pt CC) { A = AA, B = BB, C = CC; }
};
struct line {
  double A, B, C;
};
struct segment {
  pt A, B;
  segment() {}
  segment(pt AA, pt BB) { A = AA, B = BB; }
};
long double det(long double a, long double b, long double c, long double d) {
  return a * d - b * c;
}
line get_line(pt A, pt B) {
  line ans;
  ans.A = A.y - B.y;
  ans.B = B.x - A.x;
  ans.C = -ans.A * A.x - ans.B * A.y;
  return ans;
}
bool in(long double a, long double b, double c) {
  return min(a, b) <= c + eps && c - eps <= max(a, b);
}
pt intersect(pt A, pt B, pt C, pt D) {
  line l1 = get_line(A, B);
  line l2 = get_line(C, D);
  long double check = det(l1.A, l1.B, l2.A, l2.B);
  if (check) {
    long double x = -det(l1.C, l1.B, l2.C, l2.B) * 1. / check;
    long double y = -det(l1.A, l1.C, l2.A, l2.C) * 1. / check;
    if (in(A.x, B.x, x) && in(C.x, D.x, x) && in(A.y, B.y, y) &&
        in(C.y, D.y, y))
      return pt(x, y);
  }
  return pt(PI, PI);
}
vector<triangle> tr;
bool compare_pt(pt A, pt B) { return (A.x < B.x) || (A.x == B.x && A.y < B.y); }
bool left(pt A, line CUR) {
  long double tmp = CUR.A * A.x + CUR.B * A.y + CUR.C;
  return (tmp < 0);
}
bool in_triangle(pt A, pt B, triangle X) {
  pt CUR = pt((A.x + B.x) / 2, (A.y + B.y) / 2);
  line l1 = get_line(X.A, X.B);
  line l2 = get_line(X.B, X.C);
  line l3 = get_line(X.C, X.A);
  if (left(CUR, l1) && left(CUR, l2) && left(CUR, l3)) return true;
  if (!left(CUR, l1) && !left(CUR, l2) && !left(CUR, l3)) return true;
  return false;
}
long double dist(pt A, pt B) {
  long double dx = A.x - B.x;
  long double dy = A.y - B.y;
  return sqrt(dx * dx + dy * dy);
}
long double result = 0.;
void add_result(pt X, pt Y, int ind) {
  vector<pt> cur;
  cur.push_back(X);
  for (int(i) = 0; (i) < ((int)(tr).size()); (i)++) {
    if (i == ind) continue;
    pt A = intersect(X, Y, tr[i].A, tr[i].B);
    pt B = intersect(X, Y, tr[i].B, tr[i].C);
    pt C = intersect(X, Y, tr[i].C, tr[i].A);
    if (A.x != PI && A.y != PI) cur.push_back(A);
    if (B.x != PI && B.y != PI) cur.push_back(B);
    if (C.x != PI && C.y != PI) cur.push_back(C);
  }
  cur.push_back(Y);
  sort((cur).begin(), (cur).end(), compare_pt);
  for (int(i) = 0; (i) < ((int)(cur).size() - 1); (i)++) {
    bool in = false;
    for (int(j) = 0; (j) < ((int)(tr).size()); (j)++) {
      if (j == ind) continue;
      if (in_triangle(cur[i], cur[i + 1], tr[j])) in = true;
    }
    if (!in) result += dist(cur[i], cur[i + 1]);
  }
}
void check_segm() {
  for (int(i) = 0; (i) < ((int)(tr).size()); (i)++) {
    add_result(tr[i].A, tr[i].B, i);
    add_result(tr[i].B, tr[i].C, i);
    add_result(tr[i].C, tr[i].A, i);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int(i) = 0; (i) < (n); (i)++) {
    pt A, B, C;
    cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
    tr.push_back(triangle(A, B, C));
  }
  check_segm();
  cout.precision(100);
  cout << result << "\n";
  return 0;
}
