#include <bits/stdc++.h>
using namespace std;
const long long B = 101;
bool contain(const string &a, const string &b) {
  int al = a.length(), bl = b.length();
  if (al > bl) return false;
  long long ah = 0, bh = 0;
  long long t = 1;
  for (int i = 0; i < (int)(al); i++) {
    ah = ah * B + (a[i] - 'a');
    bh = bh * B + (b[i] - 'a');
    t *= B;
  }
  if (ah == bh) return true;
  for (int i = al; i < bl; ++i) {
    bh = bh * B + (b[i] - 'a') - (b[i - al] - 'a') * t;
    if (ah == bh) return true;
  }
  return false;
}
int overlap(const string &a, const string &b) {
  int al = a.length(), bl = b.length();
  int iub = min(al, bl);
  int res = 0;
  long long ah = 0, bh = 0;
  long long t = 1;
  for (int i = 0; i < iub; ++i) {
    ah = ah + (a[al - i - 1] - 'a') * t;
    bh = bh * B + (b[i] - 'a');
    t *= B;
    if (ah == bh) res = i + 1;
  }
  return res;
}
int main() {
  string in[3];
  while (cin >> in[0] >> in[1] >> in[2]) {
    vector<int> ord;
    int ovl[3][3];
    for (int i = 0; i < (int)(3); i++) {
      for (int j = 0; j < (int)(3); j++) ovl[i][j] = overlap(in[i], in[j]);
      for (int j = 0; j < (int)(3); j++)
        if (i != j && contain(in[i], in[j])) goto ng;
      ord.push_back(i);
    ng:;
    }
    if (ord.size() == 0) {
      printf("%d\n", (int)in[0].length());
      continue;
    }
    int res = 987654321;
    do {
      int tmp = 0;
      for (int i = 0; i < (int)(ord.size()); i++) tmp += in[ord[i]].length();
      for (int i = 0; i + 1 < (int)ord.size(); ++i)
        tmp -= ovl[ord[i]][ord[i + 1]];
      res = min(tmp, res);
    } while (next_permutation((ord).begin(), (ord).end()));
    printf("%d\n", res);
  }
  return 0;
}
