#include <bits/stdc++.h>
using namespace std;
const long long mxn = 2e5;
vector<long long> pow1;
vector<long long> pow2;
const long long p1 = 31;
const long long m1 = (long long)1e9 + 7;
const long long p2 = 53;
const long long m2 = (long long)1e9 + 9;
class DoubleHash {
 private:
  long long n;
  vector<long long> h1;
  vector<long long> h2;

 public:
  pair<long long, long long> get(long long l, long long r) {
    long long fi = h1[r];
    if (l >= 1) fi = (fi - h1[l - 1] + m1) % m1;
    fi = (fi * pow1[mxn - r - 1]) % m1;
    long long se = h2[r];
    if (l >= 1) se = (se - h2[l - 1] + m2) % m2;
    se = (se * pow2[mxn - r - 1]) % m2;
    return {fi, se};
  }
  bool cmp(long long l, long long r, long long l1, long long r1) {
    if (get(l, r) == get(l1, r1)) return 1;
    return 0;
  }
  void ini(long long si, string& s) {
    n = si;
    h1.resize(n + 1);
    h2.resize(n + 1);
    h1[0] = ((s[0] - 'a' + 1) * pow1[0]) % m1;
    h2[0] = ((s[0] - 'a' + 1) * pow2[0]) % m2;
    for (long long i = 1; i <= n - 1; i++) {
      h1[i] = (h1[i - 1] + pow1[i] * (s[i] - 'a' + 1)) % m1;
      h2[i] = (h2[i - 1] + pow2[i] * (s[i] - 'a' + 1)) % m2;
    }
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  pow1.resize(mxn + 1);
  pow2.resize(mxn + 1);
  pow1[0] = 1;
  pow2[0] = 1;
  for (long long i = 1; i <= mxn; i++) {
    pow1[i] = (pow1[i - 1] * p1) % m1;
    pow2[i] = (pow2[i - 1] * p2) % m2;
  }
  string s;
  vector<string> a;
  cin >> s;
  a.push_back(s);
  cin >> s;
  a.push_back(s);
  cin >> s;
  a.push_back(s);
  long long res = LLONG_MAX;
  long long c = 0;
  do {
    long long ans = 0;
    vector<DoubleHash> t(3);
    t[0].ini((long long)a[0].size(), a[0]);
    t[1].ini((long long)a[1].size(), a[1]);
    t[2].ini((long long)a[2].size(), a[2]);
    long long i = 1;
    while (i <= 2) {
      long long j = min((long long)a[i].size(), (long long)a[i - 1].size());
      while (j >= 1 && t[i - 1].get((long long)a[i - 1].size() - 1 - j + 1,
                                    (long long)a[i - 1].size() - 1) !=
                           t[i].get((long long)0, j - 1))
        j--;
      ans += (j);
      if ((long long)a[i].size() > (long long)a[i - 1].size()) {
        pair<long long, long long> temp =
            t[i - 1].get(0, (long long)a[i - 1].size() - 1);
        for (long long k = 0; k <= (long long)a[i].size() - a[i - 1].size();
             k++)
          if (t[i].get(k, k + (long long)a[i - 1].size() - 1) == temp) {
            ans = ans - j + (long long)a[i - 1].size();
            break;
          }
      } else {
        pair<long long, long long> temp =
            t[i].get(0, (long long)a[i].size() - 1);
        for (long long k = 0; k <= (long long)a[i - 1].size() - a[i].size();
             k++)
          if (t[i - 1].get(k, k + (long long)a[i].size() - 1) == temp) {
            ans = ans - j + (long long)a[i].size();
            break;
          }
      }
      i++;
    }
    res = min(res, (long long)a[0].size() + (long long)a[1].size() +
                       (long long)a[2].size() - ans);
    next_permutation(a.begin(), a.end());
    c++;
  } while (c <= 8);
  cout << res;
  return 0;
}
