#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
void solve();
int main() {
  ios::sync_with_stdio(0);
  solve();
  return 0;
}
template <class T>
T ABS(T a) {
  return a < 0 ? -a : a;
}
const long double KEps = 1.0E-8;
struct Point {
  long double x, y;
  Point(long double x = 0, long double y = 0) : x(x), y(y) {}
  bool operator<(const Point& r) const {
    return x < r.x - KEps || (ABS(x - r.x) < KEps && y < r.y - KEps);
  }
  bool operator==(const Point& r) const {
    return ABS(x - r.x) < KEps && ABS(y - r.y) < KEps;
  }
};
bool intercepts(long double x11, long double y11, long double x12,
                long double y12, long double x21, long double y21,
                long double x22, long double y22, Point& res) {
  long double a = x12 - x11, b = -(x22 - x21), c = y12 - y11, d = -(y22 - y21);
  long double dx = x21 - x11, dy = y21 - y11;
  long double det = a * d - c * b;
  if (ABS(det) < KEps) return false;
  long double t1 = (dx * d - dy * b) / det;
  long double t2 = (a * dy - c * dx) / det;
  if (t1 < -KEps) return false;
  if (t2 < -KEps) return false;
  if (t1 > 1.0 + KEps) return false;
  if (t2 > 1.0 + KEps) return false;
  res.x = x11 + a * t1;
  res.y = y11 + c * t1;
  return true;
}
int N;
int data[100][3][2];
bool testIn(long double x, long double y, int i) {
  long double angle = 0;
  for (int j = 0; j < 3; j++) {
    int nj = j + 1;
    if (nj == 3) nj = 0;
    long double ax = data[i][j][0] - x, ay = data[i][j][1] - y;
    long double bx = data[i][nj][0] - x, by = data[i][nj][1] - y;
    angle += atan2(ax * by - ay * bx, ax * bx + ay * by);
  }
  return ABS(angle) > KEps;
}
void solve() {
  vector<pair<Point, Point> > otr;
  vector<int> ids;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data[i][j][0] >> data[i][j][1];
    }
    otr.push_back(make_pair(Point(data[i][0][0], data[i][0][1]),
                            Point(data[i][1][0], data[i][1][1])));
    otr.push_back(make_pair(Point(data[i][0][0], data[i][0][1]),
                            Point(data[i][2][0], data[i][2][1])));
    otr.push_back(make_pair(Point(data[i][1][0], data[i][1][1]),
                            Point(data[i][2][0], data[i][2][1])));
    ids.push_back(i);
    ids.push_back(i);
    ids.push_back(i);
  }
  long double ans = 0;
  vector<Point> v;
  for (int i = 0; i < (int)((otr).size()); i++) {
    v.resize(0);
    v.push_back(otr[i].first);
    v.push_back(otr[i].second);
    for (int j = 0; j < (int)((otr).size()); j++) {
      if (i == j) continue;
      Point pt;
      if (intercepts(otr[i].first.x, otr[i].first.y, otr[i].second.x,
                     otr[i].second.y, otr[j].first.x, otr[j].first.y,
                     otr[j].second.x, otr[j].second.y, pt)) {
        v.push_back(pt);
      }
    }
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end()) - v.begin());
    for (int k = 0; k < (int)((v).size()) - 1; k++) {
      long double x = (v[k + 1].x + v[k].x) * 0.5;
      long double y = (v[k + 1].y + v[k].y) * 0.5;
      bool ok = true;
      for (int j = 0; j < N; j++) {
        if (j == ids[i]) continue;
        if (testIn(x, y, j)) {
          ok = false;
          break;
        }
      }
      if (ok) {
        ans += sqrtl((v[k + 1].x - v[k].x) * (v[k + 1].x - v[k].x) +
                     (v[k + 1].y - v[k].y) * (v[k + 1].y - v[k].y));
      }
    }
  }
  cout.precision(10);
  cout << fixed << ans << '\n';
}
