#include <bits/stdc++.h>
using namespace std;
string str[3];
string strTmp;
int type[6][3] = {0, 1, 2, 0, 2, 1, 1, 0, 2, 1, 2, 0, 2, 0, 1, 2, 1, 0};
const int maxn = 100005;
const unsigned long long B = 9973;
const int inf = 0x3f3f3f3f;
int cmp(string& str1, string& str2) {
  int ret = 0;
  int len1 = str1.length();
  int len2 = str2.length();
  unsigned long long ah = 0, bh = 0, tmp = 1;
  for (int i = 0; i < min(len1, len2); i++) {
    bh = bh * B + str2[i];
    ah = ah + str1[len1 - i - 1] * tmp;
    tmp *= B;
    if (bh == ah) {
      ret = i + 1;
    }
  }
  return ret;
}
bool isInside(string& str1, string& str2) {
  int len1 = str1.length();
  int len2 = str2.length();
  unsigned long long t = 1;
  for (int i = 0; i < len2; i++) t *= B;
  unsigned long long ah = 0, bh = 0;
  for (int i = 0; i < len2; i++) {
    ah = ah * B + str2[i];
    bh = bh * B + str1[i];
  }
  if (ah == bh) return 1;
  for (int i = 0; i + len2 < len1; i++) {
    bh = bh * B + str1[i + len2] - str1[i] * t;
    if (ah == bh) return 1;
  }
  return 0;
}
int main() {
  for (int i = 0; i < 3; i++) cin >> str[i];
  int ans = inf;
  for (int i = 0; i < 6; i++) {
    int tmp = str[type[i][0]].length();
    strTmp = str[type[i][0]];
    for (int j = 0; j < 2; j++) {
      if (str[type[i][j + 1]].length() <= strTmp.length()) {
        if (isInside(strTmp, str[type[i][j + 1]]) == true) {
          continue;
        }
      }
      int tt = cmp(strTmp, str[type[i][j + 1]]);
      tmp += str[type[i][j + 1]].length() - tt;
      strTmp += str[type[i][j + 1]].substr(tt, str[type[i][j + 1]].length());
    }
    ans = min(ans, tmp);
  }
  cout << ans << '\n';
  return 0;
}
