#include <bits/stdc++.h>
using namespace std;
vector<int> zf(string s) {
  int n = (int)s.length();
  vector<int> z(n);
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}
int f2(string s1, string s2) {
  string cur = s1 + '#' + s2;
  vector<int> v = zf(cur);
  int mx = 0;
  for (int i = v.size() - 1; cur[i] != '#'; --i)
    if (v[i] == v.size() - i || v[i] == s1.size()) mx = max(mx, v[i]);
  string cur2 = s2 + '#' + s1;
  v = zf(cur2);
  for (int i = v.size() - 1; cur2[i] != '#'; --i)
    if (v[i] == s2.size()) mx = max(mx, int(s2.size()));
  return mx;
}
int f(string s1, string s2, string s3) {
  return s1.size() + s2.size() + s3.size() - f2(s2, s1) - f2(s3, s2);
}
int main() {
  string s[3];
  for (int i = 0; i < 3; ++i) cin >> s[i];
  vector<int> v;
  for (int i = 0; i < 3; ++i) v.push_back(i);
  int res = 10000000;
  do {
    res = min(res, f(s[v[0]], s[v[1]], s[v[2]]));
  } while (next_permutation(v.begin(), v.end()));
  cout << res;
  return 0;
}
