#include <bits/stdc++.h>
using namespace std;
long long B = 29;
long long mod = 1e9 + 7;
long long pot[100100];
long long hPref[100100][3];
struct Cadena {
  string s;
  int tipo;
};
long long hSub(int i, int j, int tipo) {
  if (i == 0) return hPref[j][tipo];
  return (hPref[j][tipo] - (hPref[i - 1][tipo] * pot[j - i + 1]) % mod + mod) %
         mod;
}
void potencia() {
  pot[0] = 1;
  for (int i = 1; i < 100100; i++) {
    pot[i] = (pot[i - 1] * B) % mod;
  }
}
void precalc(string &s, int tipo) {
  hPref[0][tipo] = s[0] - 'a' + 1;
  for (int i = 1; i < s.size(); i++) {
    hPref[i][tipo] = ((hPref[i - 1][tipo] * B) % mod + (s[i] - 'a' + 1)) % mod;
  }
}
int minPlusLeft(Cadena &a, Cadena &centro) {
  int maxResta = 0;
  int fcentro = 0;
  int fs = a.s.size() - 1;
  int delta = 0;
  while (delta < min((int)a.s.size() - 1, (int)centro.s.size() - 1)) {
    if (hSub(fcentro, delta, centro.tipo) == hSub(fs - delta, fs, a.tipo)) {
      maxResta = delta + 1;
    }
    delta++;
  }
  return a.s.size() - maxResta;
}
int minPlusRight(Cadena &centro, Cadena &a) {
  int maxResta = 0;
  int fcentro = centro.s.size() - 1;
  int fs = 0;
  int delta = 0;
  while (delta < min((int)a.s.size() - 1, (int)centro.s.size() - 1)) {
    if (hSub(fcentro - delta, fcentro, centro.tipo) ==
        hSub(fs, delta, a.tipo)) {
      maxResta = delta + 1;
    }
    delta++;
  }
  return a.s.size() - maxResta;
}
int minLength(Cadena &A, Cadena &B, Cadena &C) {
  return minPlusLeft(A, B) + B.s.size() + minPlusRight(B, C);
}
int minLength(Cadena &A, Cadena &B) { return minPlusLeft(A, B) + B.s.size(); }
int minPermutation(Cadena &s0, Cadena &s1, Cadena &s2) {
  int minimo = 1e9;
  minimo = min(minimo, minLength(s0, s1, s2));
  minimo = min(minimo, minLength(s0, s2, s1));
  minimo = min(minimo, minLength(s1, s0, s2));
  minimo = min(minimo, minLength(s1, s2, s0));
  minimo = min(minimo, minLength(s2, s1, s0));
  minimo = min(minimo, minLength(s2, s0, s1));
  return minimo;
}
int minPermutation(Cadena &s0, Cadena &s1) {
  int minimo = 1e9;
  minimo = min(minimo, minLength(s0, s1));
  minimo = min(minimo, minLength(s1, s0));
  return minimo;
}
int minPermutation(vector<Cadena> v) {
  if (v.size() == 3) {
    return minPermutation(v[0], v[1], v[2]);
  }
  if (v.size() == 2) {
    return minPermutation(v[0], v[1]);
  }
  return v[0].s.size();
}
bool esSubstr(Cadena A, Cadena a) {
  for (int i = 0; i + a.s.size() <= A.s.size(); i++) {
    if (hSub(i, i + a.s.size() - 1, A.tipo) == hPref[a.s.size() - 1][a.tipo]) {
      return true;
    }
  }
  return false;
}
bool compara(Cadena &C1, Cadena &C2) { return C1.s.size() > C2.s.size(); }
void doit(Cadena &s0, Cadena &s1, Cadena &s2) {
  vector<Cadena> v;
  v.push_back(s0);
  v.push_back(s1);
  v.push_back(s2);
  sort(v.begin(), v.end(), compara);
  v[0].tipo = 0;
  v[1].tipo = 1;
  v[2].tipo = 2;
  precalc(v[0].s, 0);
  precalc(v[1].s, 1);
  precalc(v[2].s, 2);
  if (esSubstr(v[0], v[2])) {
    v.erase(v.begin() + 2);
  }
  if (esSubstr(v[0], v[1])) {
    v.erase(v.begin() + 1);
  }
  if (v.size() == 3) {
    if (esSubstr(v[1], v[2])) {
      v.erase(v.begin() + 2);
    }
  }
  cout << minPermutation(v) << endl;
}
int main() {
  potencia();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  Cadena s0, s1, s2;
  while (cin >> s0.s >> s1.s >> s2.s) {
    doit(s0, s1, s2);
  }
}
