#include <bits/stdc++.h>
using namespace std;
int z[1000000], len, g, k, ans = 19999999, j, i;
string st[5], s, s1;
int zz() {
  int l = 0;
  int r = 0;
  z[0] = 0;
  for (int i = 1; i < s.size(); i++) {
    z[i] = 0;
    if (i <= r) z[i] = min(z[i - l], r - i + 1);
    while (true)
      if (z[i] + i < s.size() && s[z[i]] == s[z[i] + i])
        z[i]++;
      else
        break;
    if (z[i] > 0 && i + z[i] - 1 > r) {
      l = i;
      r = i + z[i] - 1;
    }
    if (z[i] + i == s.size()) return z[i];
  }
}
int main() {
  cin >> st[0] >> st[1] >> st[2];
  for (i = 0; i <= 2; i++)
    for (j = 0; j <= 2; j++) {
      if (i != j) {
        s = st[j] + "." + st[i];
        k = zz();
        len = st[i].size() + st[j].size() - k;
        s = st[i];
        for (g = k; g < st[j].size(); g++) s += st[j][g];
        s1 = s;
        s = st[3 - i - j] + "#" + s;
        k = zz();
        int a1 = s1.size() + st[3 - i - j].size() - k;
        ans = min(ans, a1);
        s = s1 + "#" + st[3 - i - j];
        k = zz();
        a1 = s1.size() + st[3 - i - j].size() - k;
        ans = min(ans, a1);
      }
    }
  cout << ans << endl;
  return 0;
}
