#include <bits/stdc++.h>
using namespace std;
double e[4][3], x[10], y[10], tx[4][3], ty[4][3];
bool used[4];
int ans;
int sgn(double a) { return a < -1e-8 ? -1 : a > 1e-8 ? 1 : 0; }
vector<pair<double, double>> solve(double x1, double y1, double x2, double y2,
                                   double l, double l1, double l2) {
  if (sgn(l + l1 - l2) < 0 || sgn(l + l2 - l1) < 0 || sgn(l2 + l1 - l) < 0)
    return {};
  double vx = x2 - x1, vy = y2 - y1, ux = -vy, uy = vx;
  double a = ((l1 * l1 - l2 * l2) / l / l + 1) / 2;
  double d = l1 * l1 / l / l - a * a;
  if (!sgn(d)) return {{x1 + a * vx, y1 + a * vy}};
  double b = sqrt(d);
  return {{x1 + a * vx + b * ux, y1 + a * vy + b * uy},
          {x1 + a * vx - b * ux, y1 + a * vy - b * uy}};
}
bool check8() {
  for (int wb = 0; wb < 81; ++wb) {
    int w[4] = {wb % 3, wb / 3 % 3, wb / 9 % 3, wb / 27 % 3};
    double s = 0, m = 0;
    for (int i = 0; i < 4; ++i) {
      s += e[i][w[i]];
      m = max(m, e[i][w[i]]);
    }
    if (sgn(s - m - m) >= 0) return true;
  }
  return false;
}
int reduce(int ot, int t) {
  for (int i = t - 1; i >= ot; --i) {
    for (int j = 0; j < i; ++j)
      if (!sgn(x[j] - x[i]) && !sgn(y[j] - y[i])) {
        x[i] = x[t - 1];
        y[i] = y[t - 1];
        --t;
        break;
      }
  }
  return t;
}
void dfs(int t) {
  ans = min(ans, t + (!used[0] + !used[1] + !used[2] + !used[3]) * 2);
  if (t >= ans) return;
  if (used[0] && used[1] && used[2] && used[3]) {
    ans = t;
    return;
  }
  for (int i = 0; i < t; ++i)
    for (int j = 0; j < t; ++j)
      if (i != j) {
        double l2 =
            (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
        double l = hypot(x[i] - x[j], y[i] - y[j]);
        for (int k = 0; k <= 3; ++k)
          if (!used[k]) {
            used[k] = true;
            for (int z = 0; z < 3; ++z)
              if (!sgn(e[k][z] * e[k][z] - l2)) {
                double k1 = e[k][(z + 1) % 3], k2 = e[k][(z + 2) % 3];
                for (auto [nx, ny] : solve(x[i], y[i], x[j], y[j], l, k1, k2)) {
                  x[t] = nx;
                  y[t] = ny;
                  dfs(reduce(t, t + 1));
                }
              }
            used[k] = false;
          }
        for (int p = 0; p <= 3; ++p)
          if (!used[p])
            for (int q = p + 1; q <= 3; ++q)
              if (!used[q]) {
                used[p] = used[q] = true;
                for (int zp = 0; zp < 3; ++zp) {
                  double lp = e[p][zp], lp1 = e[p][(zp + 1) % 3],
                         lp2 = e[p][(zp + 2) % 3];
                  for (int zq = 0; zq < 3; ++zq) {
                    double lq = e[q][zq], lq1 = e[q][(zq + 1) % 3],
                           lq2 = e[q][(zq + 2) % 3];
                    for (auto [nx, ny] :
                         solve(x[i], y[i], x[j], y[j], l, lp, lq)) {
                      x[t] = nx, y[t] = ny;
                      auto pl = solve(x[i], y[i], nx, ny, lp, lp1, lp2);
                      for (auto pl2 : solve(x[i], y[i], nx, ny, lp, lp2, lp1))
                        pl.push_back(pl2);
                      auto ql = solve(x[j], y[j], nx, ny, lq, lq1, lq2);
                      for (auto ql2 : solve(x[j], y[j], nx, ny, lq, lq2, lq1))
                        ql.push_back(ql2);
                      for (auto [px, py] : pl)
                        for (auto [qx, qy] : ql) {
                          x[t + 1] = px, y[t + 1] = py;
                          x[t + 2] = qx, y[t + 2] = qy;
                          dfs(reduce(t, t + 3));
                        }
                    }
                  }
                }
                used[p] = used[q] = false;
              }
      }
}
int main() {
  for (int i = 0; i < 4; ++i) {
    scanf("%lf%lf%lf%lf%lf%lf", &tx[i][0], &ty[i][0], &tx[i][1], &ty[i][1],
          &tx[i][2], &ty[i][2]);
    e[i][0] = hypot(tx[i][0] - tx[i][1], ty[i][0] - ty[i][1]);
    e[i][1] = hypot(tx[i][0] - tx[i][2], ty[i][0] - ty[i][2]);
    e[i][2] = hypot(tx[i][2] - tx[i][1], ty[i][2] - ty[i][1]);
    sort(e[i], e[i] + 3);
  }
  ans = 9;
  if (check8()) --ans;
  for (int i = 0; i < 4; ++i) {
    used[i] = true;
    x[0] = tx[i][0];
    y[0] = ty[i][0];
    x[1] = tx[i][1];
    y[1] = ty[i][1];
    x[2] = tx[i][2];
    y[2] = ty[i][2];
    dfs(3);
    used[i] = false;
  }
  cout << ans << endl;
}
