#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> z_algo(string &s) {
  vector<int> z(s.size());
  z[0] = s.size();
  for (int i = 1, L = 0, R = 0; i < s.size(); i++) {
    if (i <= R) z[i] = min(R - i + 1, z[i - L]);
    while (i + z[i] < s.size() && s[z[i]] == s[i + z[i]]) z[i]++;
    if (i + z[i] - 1 > R) R = i + z[i] - 1, L = i;
  }
  return z;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  vector<string> a(3);
  for (auto &v : a) cin >> v;
  vector<int> indx(3);
  for (int i = 0; i < 3; i++) indx[i] = i;
  int ans = 1e8;
  do {
    string res = a[indx[0]];
    string temp = a[indx[1]] + "#" + res;
    vector<int> z = z_algo(temp);
    int ma = 0;
    for (int i = a[indx[1]].size(); i < temp.size(); i++) {
      if (i + z[i] == temp.size() || z[i] == a[indx[1]].size())
        ma = max(ma, z[i]);
    }
    res += a[indx[1]].substr(ma, a[indx[1]].size() - ma);
    temp = a[indx[2]] + "#" + res;
    z = z_algo(temp);
    ma = 0;
    for (int i = a[indx[2]].size(); i < temp.size(); i++) {
      if (i + z[i] == temp.size() || z[i] == a[indx[2]].size())
        ma = max(ma, z[i]);
    }
    res += a[indx[2]].substr(ma, a[indx[2]].size() - ma);
    ans = min(ans, (int)res.size());
  } while (next_permutation(indx.begin(), indx.end()));
  cout << ans << endl;
  return 0;
}
