#include <bits/stdc++.h>
using namespace std;
const int mm = 100040;
int nxt[3][mm], l[3];
char s[3][mm];
void get(int x) {
  int k = -1, j = 0;
  nxt[x][0] = -1;
  while (j < l[x]) {
    if (k == -1 || s[x][k] == s[x][j]) {
      ++k;
      ++j;
      nxt[x][j] = k;
    } else
      k = nxt[x][k];
  }
}
int kmp(int x, int y) {
  int j = 0, k = 0;
  while (j < l[y] && k < l[x]) {
    if (j == -1 || s[x][k] == s[y][j]) {
      ++j;
      ++k;
    } else
      j = nxt[y][j];
  }
  return j;
}
int main() {
  while (cin >> s[0] >> s[1] >> s[2]) {
    l[0] = strlen(s[0]);
    l[1] = strlen(s[1]);
    l[2] = strlen(s[2]);
    for (int i = 0; i < 3; i++) get(i);
    int ans = -3333;
    int z, zz = 0;
    z = kmp(0, 1);
    zz = z;
    if (l[1] == z)
      zz += kmp(0, 2);
    else
      zz += kmp(1, 2);
    ans = ans > zz ? ans : zz;
    z = kmp(0, 2);
    zz = z;
    if (l[2] == z)
      zz += kmp(0, 1);
    else
      zz += kmp(2, 1);
    ans = ans > zz ? ans : zz;
    z = kmp(1, 0);
    zz = z;
    if (l[0] == z)
      zz += kmp(1, 2);
    else
      zz += kmp(0, 2);
    ans = ans > zz ? ans : zz;
    z = kmp(1, 2);
    zz = z;
    if (l[2] == z)
      zz += kmp(1, 0);
    else
      zz += kmp(2, 0);
    ans = ans > zz ? ans : zz;
    z = kmp(2, 0);
    zz = z;
    if (l[0] == z)
      zz += kmp(2, 1);
    else
      zz += kmp(0, 1);
    ans = ans > zz ? ans : zz;
    ;
    z = kmp(2, 1);
    zz = z;
    if (l[1] == z)
      zz += kmp(2, 0);
    else
      zz += kmp(1, 0);
    ans = ans > zz ? ans : zz;
    zz = l[0] + l[1] + l[2];
    zz = zz - ans;
    cout << zz << "\n";
  }
  return 0;
}
