#include <bits/stdc++.h>
const int MaxN = 5;
const int Maxlen = 100008;
bool vis[MaxN][MaxN];
char str[MaxN][Maxlen];
int n, len[MaxN], Belong[MaxN][MaxN], fail[MaxN][Maxlen];
inline void Checkmin(int &a, int b) { a = b < a ? b : a; }
void get_fail(int id) {
  int i, j;
  fail[id][0] = -1;
  for (i = 1; i < len[id]; i++) {
    j = fail[id][i - 1];
    while (j != -1 && str[id][i] != str[id][j + 1]) j = fail[id][j];
    if (str[id][i] == str[id][j + 1]) {
      fail[id][i] = j + 1;
    } else {
      fail[id][i] = -1;
    }
  }
}
int KMP(int id1, int id2) {
  int i, j, ret;
  i = j = ret = 0;
  while (i < len[id1] && j < len[id2]) {
    if (str[id1][i] == str[id2][j]) {
      i++;
      j++;
      if (j == len[id2]) {
        ret = j;
        break;
      }
      if (i == len[id1]) ret = j;
    } else if (j) {
      j = fail[id2][j - 1] + 1;
    } else {
      i++;
    }
  }
  if (ret == len[id2]) {
    vis[id1][id2] = true;
  }
  return ret;
}
int main() {
  int i, j, k, best;
  memset(str, '\0', sizeof(str));
  while (scanf("%s", str[0]) != EOF) {
    n = 3;
    for (i = 1; i < n; i++) {
      scanf("%s", str[i]);
    }
    for (i = 0; i < n; i++) {
      len[i] = strlen(str[i]);
      get_fail(i);
    }
    memset(vis, false, sizeof(vis));
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (i == j) continue;
        Belong[i][j] = KMP(i, j);
      }
    }
    best = len[0] + len[1] + len[2];
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (i == j) continue;
        k = n - i - j;
        if (vis[i][j] && vis[i][k]) {
          Checkmin(best, len[i]);
          continue;
        }
        if (vis[i][j]) {
          Checkmin(best, len[i] + len[k] - Belong[i][k]);
          continue;
        }
        if (vis[j][k]) {
          Checkmin(best, len[i] + len[j] - Belong[i][j]);
          continue;
        }
        Checkmin(best, len[i] + len[j] + len[k] - Belong[i][j] - Belong[j][k]);
      }
    }
    printf("%d\n", best);
  }
  return 0;
}
