#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void Int(T &n) {
  n = 0;
  int f = 1;
  register int ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
template <typename T>
T gcd(T a, T b) {
  return !b ? a : gcd(b, a % b);
}
template <typename T>
inline void umin(T &a, T b) {
  a = a < b ? a : b;
}
template <typename T>
inline void umax(T &a, T b) {
  a = a > b ? a : b;
}
template <typename T, typename W>
inline void Int(T &x, W &y) {
  Int(x), Int(y);
}
template <typename T, typename W, typename Q>
inline void Int(T &x, W &y, Q &z) {
  Int(x, y), Int(z);
}
const int P = 131;
const int N = 2e5 + 7;
const int inf = 1e9 + 7;
char s[5][N];
unsigned long long Pow[N];
struct StringHashing {
  unsigned long long Hash[N];
  void BuildHash(char *t) {
    for (int i = 0; t[i]; i++) {
      Hash[i] = Pow[i] * t[i];
      if (i) Hash[i] += Hash[i - 1];
    }
  }
  inline unsigned long long GetHash(int l, int r) {
    return l ? Hash[r] - Hash[l - 1] : Hash[r];
  }
} h[5];
int solve() {
  Pow[0] = 1;
  for (int i = 1; i < N; i++) {
    Pow[i] = Pow[i - 1] * P;
  }
  int len[5];
  for (int i = 0; i <= 2; ++i) {
    scanf("%s", s[i]);
    h[i].BuildHash(s[i]);
    len[i] = strlen(s[i]) - 1;
  }
  int res = len[0] + len[1] + len[2] + 3;
  vector<int> idx = {0, 1, 2};
  do {
    int j, tmp, cur = len[0] + len[1] + len[2] + 3;
    j = tmp = 0;
    for (int i = len[idx[0]]; i >= 0; --i) {
      unsigned long long hl = h[idx[0]].GetHash(i, i + j);
      unsigned long long hr = h[idx[1]].GetHash(0, j) * Pow[i];
      if (hl == hr) tmp = j + 1;
      j = min(j + 1, len[idx[1]]);
    }
    cur -= tmp;
    memcpy(h[3].Hash, h[idx[0]].Hash, sizeof(h[idx[0]].Hash));
    len[3] = len[idx[0]];
    for (int i = tmp; i <= len[idx[1]]; ++i) {
      ++len[3];
      h[3].Hash[len[3]] = h[3].Hash[len[3] - 1] + Pow[len[3]] * s[idx[1]][i];
    }
    j = tmp = 0;
    for (int i = len[3]; i >= 0; --i) {
      unsigned long long hl = h[3].GetHash(i, i + j);
      unsigned long long hr = h[idx[2]].GetHash(0, j) * Pow[i];
      if (hl == hr) tmp = j + 1;
      j = min(j + 1, len[idx[2]]);
    }
    cur -= tmp;
    umin(res, cur);
  } while (next_permutation(idx.begin(), idx.end()));
  printf("%d\n", res);
  return 0;
}
int main() {
  int tests = 1, CaseNo = 0;
  while (tests--) {
    solve();
  }
  return 0;
}
