#include <bits/stdc++.h>
using namespace std;
const unsigned long long bas = 1e8 + 7;
string s[4];
int pl[6][3] = {1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1};
bool contain(string a, string b) {
  int lena = a.size(), lenb = b.size();
  if (lena > lenb) {
    return 0;
  }
  unsigned long long t = 1;
  for (int i = 0; i < lena; i++) {
    t *= bas;
  }
  unsigned long long ahash = 0, bhash = 0;
  for (int i = 0; i < lena; i++) {
    ahash = ahash * bas + a[i];
    bhash = bhash * bas + b[i];
  }
  for (int i = 0; i + lena <= lenb; i++) {
    if (ahash == bhash) {
      return 1;
    }
    if (i + lena < lenb) {
      bhash = bhash * bas + b[i + lena] - b[i] * t;
    }
  }
  return 0;
}
int overlap(string a, string b) {
  int lena = a.size(), lenb = b.size();
  int ans = 0;
  unsigned long long ahash = 0, bhash = 0, t = 1;
  for (int i = 1; i <= min(lena, lenb); i++) {
    ahash = ahash + a[lena - i] * t;
    bhash = bhash * bas + b[i - 1];
    if (ahash == bhash) {
      ans = i;
    }
    t *= bas;
  }
  return ans;
}
int main() {
  cin >> s[1] >> s[2] >> s[3];
  int ans = 0x7f7f7f7f;
  for (int i = 0; i < 6; i++) {
    int l1, l2;
    if (contain(s[pl[i][0]], s[pl[i][1]])) {
      l1 = s[pl[i][0]].size();
    } else {
      l1 = overlap(s[pl[i][0]], s[pl[i][1]]);
    }
    if (contain(s[pl[i][2]], s[pl[i][1]])) {
      l2 = s[pl[i][2]].size();
    } else {
      l2 = overlap(s[pl[i][1]], s[pl[i][2]]);
    }
    ans = min(ans, (int)(s[3].size() + s[1].size() + s[2].size() - l1 - l2));
  }
  cout << ans << endl;
}
