#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const unsigned long long seed = 131313;
unsigned long long b[N], h[3][N];
void init() {
  b[0] = 1;
  for (int i = 1; i < N; i++) b[i] = b[i - 1] * seed;
}
void init_hash(unsigned long long* h, const char* str) {
  h[0] = 0;
  for (int i = 1; *str; i++) h[i] = h[i - 1] * seed + (*str++);
}
unsigned long long BKDR_hash(unsigned long long* h, int l, int r) {
  return h[r + 1] - h[l] * b[r - l + 1];
}
string s[3];
int len[3][3], a[3] = {0, 1, 2};
int contains(int x, int y) {
  if (s[x].size() > s[y].size()) return 0;
  for (int i = 0; i <= s[y].size() - s[x].size(); i++)
    if (BKDR_hash(h[x], 0, s[x].size() - 1) ==
        BKDR_hash(h[y], i, i + s[x].size() - 1))
      return 1;
  return 0;
}
int main() {
  init();
  int n = 0;
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
    init_hash(h[i], s[i].c_str());
    n += s[i].size();
  }
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) len[i][j] = contains(i, j);
  int ans = n;
  if (len[0][1] || len[0][2]) ans -= s[0].size();
  if (len[1][0] || len[1][2]) ans -= s[1].size();
  if (len[2][0] || len[2][1]) ans -= s[2].size();
  if (ans == 0) ans = max(s[0].size(), max(s[1].size(), s[2].size()));
  int tmp = ans;
  do {
    int l1 = 0, l2 = 0;
    for (int i = 0; i < s[a[0]].size() && i < s[a[1]].size(); i++)
      if (BKDR_hash(h[a[0]], s[a[0]].size() - 1 - i, s[a[0]].size() - 1) ==
          BKDR_hash(h[a[1]], 0, i))
        l1 = max(l1, i + 1);
    for (int i = 0; i < s[a[1]].size() && i < s[a[2]].size(); i++)
      if (BKDR_hash(h[a[1]], s[a[1]].size() - 1 - i, s[a[1]].size() - 1) ==
          BKDR_hash(h[a[2]], 0, i))
        l2 = max(l2, i + 1);
    if (len[a[0]][a[1]] || len[a[1]][a[0]]) l1 = 0;
    if (len[a[1]][a[2]] || len[a[2]][a[1]]) l2 = 0;
    ans = min(ans, tmp - l1 - l2);
  } while (next_permutation(a, a + 3));
  cout << ans << endl;
  return 0;
}
