#include <bits/stdc++.h>
using namespace std;
char s[3][100000 + 1];
int pref[3][100000];
void kmp(int id, int L) {
  pref[id][0] = 0;
  for (int i = 1, k = 0; i < L; ++i) {
    while (k > 0 && s[id][i] != s[id][k]) k = pref[id][k - 1];
    if (s[id][i] == s[id][k]) ++k;
    pref[id][i] = k;
  }
}
int kmp_match(int id1, int L1, int id2, int L2) {
  int k = 0;
  for (int i = 0; i < L1; ++i) {
    while (k > 0 && s[id1][i] != s[id2][k]) k = pref[id2][k - 1];
    if (s[id1][i] == s[id2][k]) ++k;
    if (k == L2) return L2;
  }
  return k;
}
int main() {
  int L[3];
  for (int i = 0; i < 3; ++i) {
    scanf("%s", s[i]);
    L[i] = strlen(s[i]);
    kmp(i, L[i]);
  }
  int match[3][3];
  bool is_substr[3];
  memset(is_substr, false, sizeof is_substr);
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (i != j) {
        match[i][j] = kmp_match(i, L[i], j, L[j]);
        if ((L[i] > L[j] || (j < i && L[i] == L[j])) && match[i][j] == L[j])
          is_substr[j] = true;
      }
    }
  }
  vector<int> ind;
  for (int i = 0; i < 3; ++i)
    if (!is_substr[i]) ind.push_back(i);
  int n = ind.size(), ans = L[0] + L[1] + L[2];
  do {
    int total = L[ind[0]];
    for (int i = 1; i < n; ++i) total += L[ind[i]] - match[ind[i - 1]][ind[i]];
    ans = min(ans, total);
  } while (next_permutation(ind.begin(), ind.end()));
  printf("%d\n", ans);
  return 0;
}
