#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-8;
struct Point {
  long double x, y;
  Point() {}
  Point(long double xx, long double yy) {
    x = xx;
    y = yy;
  }
  Point operator+(Point a) { return Point(x + a.x, y + a.y); }
  Point operator-(Point a) { return Point(x - a.x, y - a.y); }
  Point operator*(long double c) { return Point(x * c, y * c); }
  Point operator/(long double c) { return Point(x / c, y / c); }
  bool operator<(const Point &a) const {
    return (abs(x - a.x) < eps) ? (y < a.y) : (x < a.x);
  }
  bool operator==(const Point &a) const {
    return (abs(x - a.x) < eps) && (abs(y - a.y) < eps);
  }
};
inline long double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
inline int sign(long double x) {
  if (abs(x) < eps) return 0;
  if (x > 0) return 1;
  return -1;
}
inline bool isInside(Point a, Point b, Point c, Point x) {
  int as = sign(cross(a - x, b - x));
  int bs = sign(cross(b - x, c - x));
  int cs = sign(cross(c - x, a - x));
  return (as == bs) && (bs == cs);
}
inline void intersect(Point a, Point b, Point c, Point d, vector<Point> &v) {
  long double x0 = a.x - c.x;
  long double y0 = a.y - c.y;
  long double x1 = a.x - b.x;
  long double y1 = a.y - b.y;
  long double x2 = c.x - d.x;
  long double y2 = c.y - d.y;
  long double det = x1 * y2 - x2 * y1;
  if (abs(det) < eps) return;
  long double t = (y2 * x0 - x2 * y0) / det;
  long double s = (y1 * x0 - x1 * y0) / det;
  if (t < 0 || t > 1 || s < 0 || s > 1) return;
  v.push_back(a + (b - a) * t);
}
inline long double dist(Point a, Point b) {
  a = a - b;
  return sqrt(a.x * a.x + a.y * a.y);
}
Point tang[105][3];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(32);
  int n;
  cin >> n;
  vector<pair<Point, Point> > seg;
  for (int i = 0; i < n; i++) {
    cin >> tang[i][0].x >> tang[i][0].y;
    cin >> tang[i][1].x >> tang[i][1].y;
    cin >> tang[i][2].x >> tang[i][2].y;
    seg.push_back({tang[i][0], tang[i][1]});
    seg.push_back({tang[i][1], tang[i][2]});
    seg.push_back({tang[i][2], tang[i][0]});
  }
  long double ans = 0.0;
  for (int i = 0; i < seg.size(); i++) {
    vector<Point> v;
    for (int j = 0; j < seg.size(); j++) {
      if (i == j) continue;
      intersect(seg[i].first, seg[i].second, seg[j].first, seg[j].second, v);
    }
    v.push_back(seg[i].first);
    v.push_back(seg[i].second);
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end()) - v.begin());
    for (int j = 1; j < v.size(); j++) {
      Point md = (v[j] + v[j - 1]) / 2;
      bool flg = true;
      for (int k = 0; k < n; k++) {
        if (isInside(tang[k][0], tang[k][1], tang[k][2], md)) {
          flg = false;
          break;
        }
      }
      if (flg) ans += dist(v[j], v[j - 1]);
    }
  }
  cout << ans;
  return 0;
}
