#include <bits/stdc++.h>
using namespace std;
int KMP(string s1, string s2, int F[100001]) {
  int m = 0, i = 0;
  while (m + i < s1.length()) {
    if (s1[m + i] == s2[i])
      i++;
    else {
      m = m + i - F[i];
      i = F[i];
      if (i < 0) i = 0;
    }
    if (i == s2.length()) return i;
  }
  return i;
}
void Failure(string s, int F[100001]) {
  F[0] = -1;
  F[1] = 0;
  int pos = 2, cnd = 0;
  while (pos <= s.length()) {
    if (s[pos - 1] == s[cnd]) {
      F[pos] = cnd + 1;
      cnd++;
      pos++;
    } else if (cnd > 0)
      cnd = F[cnd];
    else {
      F[pos] = 0;
      pos++;
    }
  }
}
int F[100001];
int main() {
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  int L = s[0].length() + s[1].length() + s[2].length();
  int k = 0;
  while (k < 6) {
    Failure(s[1], F);
    int l = s[0].length() + s[1].length() + s[2].length();
    int l1 = KMP(s[0], s[1], F);
    Failure(s[2], F);
    if (l1 == s[1].length()) {
      l -= KMP(s[0], s[2], F);
    } else
      l -= KMP(s[1], s[2], F);
    L = min(L, l - l1);
    next_permutation(s, s + 3);
    k++;
  }
  cout << L << endl;
  return 0;
}
