#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const unsigned long long inf = 1e18 + 10, mxn = 1e5 + 10, base1 = 311,
                         base2 = 331, base3 = 173;
unsigned long long res, ans, delay, p1[mxn], p2[mxn], p3[mxn], h1[3][mxn],
    h2[3][mxn], h3[3][mxn];
vector<pair<unsigned long long, string>> s(3);
unsigned long long hsh1(unsigned long long x, unsigned long long xend,
                        unsigned long long pos) {
  return h1[s[pos].first][xend] - h1[s[pos].first][x] * p1[xend - x];
}
unsigned long long hsh2(unsigned long long x, unsigned long long xend,
                        unsigned long long pos) {
  return h2[s[pos].first][xend] - h2[s[pos].first][x] * p2[xend - x];
}
unsigned long long hsh3(unsigned long long x, unsigned long long xend,
                        unsigned long long pos) {
  return h3[s[pos].first][xend] - h3[s[pos].first][x] * p3[xend - x];
}
bool in(unsigned long long pos1, unsigned long long pos2) {
  unsigned long long x = 0, xend = s[pos2].second.size();
  while (xend <= s[pos1].second.size()) {
    if (hsh1(x, xend, pos1) == h1[s[pos2].first][s[pos2].second.size()] &&
        hsh2(x, xend, pos1) == h2[s[pos2].first][s[pos2].second.size()] &&
        hsh3(x, xend, pos1) == h3[s[pos2].first][s[pos2].second.size()])
      return true;
    x++;
    xend++;
  }
  return false;
}
unsigned long long Prefix(unsigned long long pos1, unsigned long long pos2) {
  unsigned long long mx = 0;
  for (unsigned long long i = 1;
       i <= min(s[pos1].second.size(), s[pos2].second.size()); i++) {
    unsigned long long tam = s[pos1].second.size();
    if (hsh1(tam - i, tam, pos1) == h1[s[pos2].first][i] &&
        hsh2(tam - i, tam, pos1) == h2[s[pos2].first][i] &&
        hsh3(tam - i, tam, pos1) == h3[s[pos2].first][i])
      mx = i;
  }
  return mx;
}
void Solve() {
  p1[0] = 1;
  for (unsigned long long i = 1; i < mxn; i++) p1[i] = p1[i - 1] * base1;
  p2[0] = 1;
  for (unsigned long long i = 1; i < mxn; i++) p2[i] = p2[i - 1] * base2;
  p3[0] = 1;
  for (unsigned long long i = 1; i < mxn; i++) p3[i] = p3[i - 1] * base3;
  ans = inf;
  for (unsigned long long i = 0; i < 3; i++) {
    cin >> s[i].second;
    s[i].first = i;
    h1[i][0] = 0;
    for (unsigned long long j = 1; j <= s[i].second.size(); j++)
      h1[i][j] = h1[i][j - 1] * base1 + (s[i].second[j - 1] - 'a' + 1);
    h2[i][0] = 0;
    for (unsigned long long j = 1; j <= s[i].second.size(); j++)
      h2[i][j] = h2[i][j - 1] * base2 + (s[i].second[j - 1] - 'a' + 1);
    h3[i][0] = 0;
    for (unsigned long long j = 1; j <= s[i].second.size(); j++)
      h3[i][j] = h3[i][j - 1] * base3 + (s[i].second[j - 1] - 'a' + 1);
  }
  do {
    res = s[0].second.size();
    delay = 1;
    for (unsigned long long i = 1; i < 3; i++) {
      if (in(i - delay, i)) {
        delay++;
        continue;
      } else {
        res += s[i].second.size() - Prefix(i - delay, i);
        delay = 1;
      }
    }
    ans = min(ans, res);
  } while (next_permutation(s.begin(), s.end()));
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  cout.setf(ios::fixed);
  cout.precision(0);
  Solve();
  return 0;
}
