#include <bits/stdc++.h>
using namespace std;
int nt[200010], ans;
void get_next(string t) {
  memset(nt, 0, sizeof(nt));
  for (int i = 1; i < t.length(); i++) {
    int j = nt[i];
    while (j && t[i] != t[j]) j = nt[j];
    nt[i + 1] = (t[i] == t[j]) ? j + 1 : 0;
  }
}
int kmp(string s, string t) {
  int ans = 0;
  get_next(t);
  int j = 0;
  for (int i = 0; i < s.length(); i++) {
    while (j && s[i] != t[j]) j = nt[j];
    if (s[i] == t[j]) j++;
    if (j == t.length()) return j;
  }
  return j;
}
void combine(string s1, string s2, string s3) {
  string str;
  int k;
  str = s1 + s2;
  k = str.length() + s3.length() - kmp(str, s3);
  ans = min(ans, k);
  str = s1;
  k = kmp(s1, s2);
  if (k != s2.length())
    for (int i = k; i < s2.length(); i++) str += s2[i];
  k = str.length() + s3.length() - kmp(str, s3);
  ans = min(ans, k);
}
int main() {
  string s1, s2, s3;
  while (cin >> s1 >> s2 >> s3) {
    ans = s1.length() + s2.length() + s3.length();
    combine(s1, s2, s3);
    combine(s1, s3, s2);
    combine(s2, s1, s3);
    combine(s2, s3, s1);
    combine(s3, s1, s2);
    combine(s3, s2, s1);
    printf("%d\n", ans);
  }
  return 0;
}
