#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
long long POW[100000 + 1];
string solve(string x, string y) {
  int size = 0, ans = 0;
  int N = x.size();
  int M = y.size();
  long long h1 = 0, h2 = 0;
  POW[0] = 1;
  for (; size < N; size++) {
    if (size < y.size()) {
      h1 += (POW[size] * (y[size] - 'a')) % 2000000007;
      h1 %= 2000000007;
      POW[size + 1] = POW[size] * 26;
      POW[size + 1] %= 2000000007;
    } else {
      h2 -=
          (POW[y.size() - 1] * (x[N - 1 - size + y.size()] - 'a')) % 2000000007;
      while (h2 < 0) h2 += 2000000007;
      h2 %= 2000000007;
    }
    h2 *= 26;
    h2 %= 2000000007;
    h2 += x[N - 1 - size] - 'a';
    h2 %= 2000000007;
    if (h1 == h2) ans = size + 1;
  }
  return x + (ans >= y.size() ? "" : y.substr(ans));
}
int solve(string x, string y, string z) { return solve(solve(x, y), z).size(); }
int A[6];
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int i = 0;
  A[i] = solve(a, b, c);
  i++;
  A[i] = solve(a, c, b);
  i++;
  A[i] = solve(b, c, a);
  i++;
  A[i] = solve(b, a, c);
  i++;
  A[i] = solve(c, a, b);
  i++;
  A[i] = solve(c, b, a);
  i++;
  cout << *min_element(A, A + 6);
  return 0;
}
