#include <bits/stdc++.h>
using namespace std;
struct Point {
  long double x, y;
  Point(long double x = 0.0, long double y = 0.0) : x(x), y(y) {}
};
const long double eps = 1e-8;
const long double inf = 1e30;
const long double pi = acos(-1.0);
bool operator<(const Point &a, const Point &b) { return a.x < b.x; }
inline bool eq(long double x, long double y) { return fabs(x - y) <= eps; }
inline bool le(long double x, long double y) { return x <= y || eq(x, y); }
inline bool lt(long double x, long double y) { return x < y && !eq(x, y); }
inline bool ge(long double x, long double y) { return x >= y || eq(x, y); }
inline bool gt(long double x, long double y) { return x > y && !eq(x, y); }
inline Point operator+(Point a, Point b) { return Point(a.x + b.x, a.y + b.y); }
inline Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); }
inline Point operator*(Point a, long double b) {
  return Point(a.x * b, a.y * b);
}
inline Point normal(Point p) { return Point(p.y, -p.x); }
inline long double vect(Point a, Point b) { return a.x * b.y - a.y * b.x; }
inline long double scal(Point a, Point b) { return a.x * b.x + a.y * b.y; }
inline long double sqr(long double x) { return x * x; }
inline long double dist(Point a) { return sqrt(sqr(a.x) + sqr(a.y)); }
inline int sgn(long double x) { return eq(x, 0.0) ? 0 : (x > 0 ? 1 : -1); }
long double ans = 0.0;
int N;
Point P[1000][3];
bool inside(Point *p, Point q) {
  int g1 = 0, l1 = 0;
  for (int i = 0; i < 3; ++i) {
    int j = (i + 1) % 3;
    int s = sgn(vect(p[j] - p[i], q - p[i]));
    if (s > 0) g1++;
    if (s < 0) l1++;
  }
  return g1 == 3 || l1 == 3;
}
bool check(Point p1, Point p2) {
  Point q = (p1 + p2) * 0.5;
  for (int i = 0; i < N; ++i) {
    if (inside(P[i], q)) return false;
  }
  return true;
}
bool crossSegments(Point p1, Point p2, Point p3, Point p4) {
  return le(min(p1.x, p2.x), max(p3.x, p4.x)) &&
         le(min(p3.x, p4.x), max(p1.x, p2.x)) &&
         le(min(p1.y, p2.y), max(p3.y, p4.y)) &&
         le(min(p3.y, p4.y), max(p1.y, p2.y)) &&
         sgn(vect(p2 - p1, p3 - p1)) * sgn(vect(p2 - p1, p4 - p1)) <= 0 &&
         sgn(vect(p4 - p3, p1 - p3)) * sgn(vect(p4 - p3, p2 - p3)) <= 0;
}
Point crossLines(Point p1, Point p2, Point p3, Point p4) {
  long double t = vect(p2 - p1, p4 - p3);
  return p1 + (p2 - p1) * (vect(p4 - p3, p1 - p3) / t);
}
void process(int skipI, Point p1, Point p2) {
  vector<pair<long double, Point> > v;
  v.push_back(make_pair(0, p1));
  for (int i = 0; i < N; ++i) {
    if (skipI == i) continue;
    for (int j = 0; j < 3; ++j) {
      int k = (j + 1) % 3;
      if (!crossSegments(p1, p2, P[i][j], P[i][k])) continue;
      Point q = crossLines(p1, p2, P[i][j], P[i][k]);
      long double d = dist(q - p1);
      v.push_back(make_pair(d, q));
    }
  }
  sort((v).begin(), (v).end());
  v.push_back(make_pair(0, p2));
  for (int i = 0; i + 1 < ((int)(v.size())); ++i) {
    if (check(v[i].second, v[i + 1].second)) {
      ans += dist(v[i].second - v[i + 1].second);
    }
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> P[i][j].x >> P[i][j].y;
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; ++j) {
      int k = (j + 1) % 3;
      process(i, P[i][j], P[i][k]);
    }
  }
  double out = (double)ans;
  printf("%0.12lf\n", out);
  return 0;
}
