#include <bits/stdc++.h>
using namespace std;
namespace zzc {
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
const int maxn = 2e5 + 5;
int ans = 0x3f3f3f3f;
char s[3][maxn];
int nxt[3][maxn], len[3], overlap[3][3];
void init(int id) {
  for (int i = 2, j = 0; i <= len[id]; i++) {
    while (j && s[id][i] != s[id][j + 1]) j = nxt[id][j];
    if (s[id][i] == s[id][j + 1]) j++;
    nxt[id][i] = j;
  }
}
int kmp(int x, int y) {
  int j = 0;
  for (int i = 1; i <= len[x]; i++) {
    while (j && s[x][i] != s[y][j + 1]) j = nxt[y][j];
    if (s[x][i] == s[y][j + 1]) j++;
    if (j == len[y]) return len[y];
  }
  return j;
}
int calc(int x, int y, int z) {
  if (overlap[x][y] == len[y] && overlap[y][z] == len[z])
    return len[x];
  else if (overlap[x][y] == len[y])
    return len[x] + len[z] - overlap[x][z];
  else if (overlap[y][z] == len[z])
    return len[x] + len[y] - overlap[x][y];
  else
    return len[x] + len[y] + len[z] - overlap[x][y] - overlap[y][z];
}
void work() {
  for (int i = 0; i <= 2; i++)
    scanf("%s", s[i] + 1), len[i] = strlen(s[i] + 1), init(i);
  for (int i = 0; i <= 2; i++)
    for (int j = 0; j <= 2; j++)
      if (i != j) overlap[i][j] = kmp(i, j);
  ans = min(ans, calc(0, 1, 2));
  ans = min(ans, calc(0, 2, 1));
  ans = min(ans, calc(1, 0, 2));
  ans = min(ans, calc(1, 2, 0));
  ans = min(ans, calc(2, 0, 1));
  ans = min(ans, calc(2, 1, 0));
  printf("%d\n", ans);
}
}  // namespace zzc
int main() {
  zzc::work();
  return 0;
}
