#include <bits/stdc++.h>
using namespace std;
long long power[100000];
long long h[3][100000];
int d[3][3];
string a[3];
bool ok(int i, int j, int pos) {
  long long h1 = h[i][a[i].length() - 1] - h[i][a[i].length() - pos - 1];
  long long h2 = h[j][pos - 1] * power[a[i].length() - pos];
  if (h1 == h2) return true;
  return false;
}
int main() {
  power[0] = 1LL;
  for (int i = 1; i < 100000; i++) power[i] = power[i - 1] * 100699LL;
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i].length(); j++) {
      h[i][j] = (a[i][j] - 96) * power[j] + ((j == 0) ? 0 : h[i][j - 1]);
    }
  }
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      if (a[j].find(a[i]) != string::npos)
        d[i][j] = a[i].length();
      else {
        int pos = 0;
        for (int k = 1; k < min(a[i].length(), a[j].length()); k++)
          if (ok(i, j, k)) pos = k;
        d[i][j] = pos;
      }
  int mi = 1000000000;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
        if (i != j && j != k && i != k) {
          int cur = 0;
          if (d[i][j] == d[i][i]) {
            cur += d[j][j];
            cur += d[k][k] - d[j][k];
          } else if (d[j][k] == d[j][j]) {
            cur += d[k][k];
            cur += d[i][i] - d[i][k];
          } else {
            cur = d[i][i] + d[j][j] + d[k][k] - d[i][j] - d[j][k];
          }
          mi = min(mi, cur);
        }
  cout << mi << endl;
  return 0;
}
