#include <bits/stdc++.h>
using namespace std;
using namespace std;
int PI[1000008];
string s;
void preKMP() {
  int m = s.length();
  PI[0] = 0;
  int k = 0;
  for (int q = 1; q < m; q++) {
    while (k > 0 && s[k] != s[q]) k = PI[k - 1];
    if (s[k] == s[q]) k = k + 1;
    PI[q] = k;
  }
}
vector<int> v;
string t;
string p;
void KMP() {
  v.clear();
  int n = t.length(), m = p.length();
  s = p;
  preKMP();
  int q = 0;
  for (int i = 0; i < n; i++) {
    while (q > 0 && p[q] != t[i]) q = PI[q - 1];
    if (p[q] == t[i]) q = q + 1;
    if (q == m) {
      v.push_back(i - m + 1);
      q = PI[q - 1];
    }
  }
}
int main() {
  int arr[3][3];
  string inp[3];
  for (int i = 0; i < 3; i++) {
    string s1;
    cin >> s1;
    inp[i] = s1;
  }
  if (inp[0].size() > inp[1].size()) {
    swap(inp[0], inp[1]);
  }
  if (inp[1].size() > inp[2].size()) {
    swap(inp[1], inp[2]);
  }
  if (inp[0].size() > inp[1].size()) {
    swap(inp[0], inp[1]);
  }
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) {
      if (i == j) {
        arr[i][j] = 0;
        continue;
      }
      s = inp[j] + "#" + inp[i];
      preKMP();
      arr[i][j] = PI[s.size() - 1];
    }
  t = inp[1];
  p = inp[0];
  KMP();
  if (v.size() == 0) {
    t = inp[2];
    p = inp[1];
    KMP();
    if (v.size() == 0) {
      t = inp[2];
      p = inp[0];
      KMP();
      if (v.size() == 0) {
        int myints[] = {0, 1, 2};
        int maxv = 0;
        do {
          maxv =
              max(maxv, arr[myints[0]][myints[1]] + arr[myints[1]][myints[2]]);
        } while (next_permutation(myints, myints + 3));
        printf("%d\n", inp[0].size() + inp[1].size() + inp[2].size() - maxv);
      } else {
        printf("%d\n",
               inp[1].size() + inp[2].size() - max(arr[1][2], arr[2][1]));
      }
    } else {
      t = inp[2];
      p = inp[0];
      KMP();
      if (v.size() == 0) {
        printf("%d\n",
               inp[0].size() + inp[2].size() - max(arr[0][2], arr[2][0]));
      } else {
        printf("%d\n", inp[2].size());
      }
    }
  } else {
    t = inp[2];
    p = inp[1];
    KMP();
    if (v.size() == 0) {
      printf("%d\n", inp[1].size() + inp[2].size() - max(arr[1][2], arr[2][1]));
    } else {
      printf("%d\n", inp[2].size());
    }
  }
}
