#include <bits/stdc++.h>
using namespace std;
namespace Fastio {
inline long long read() {
  long long w = 0, x = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return w ? -x : x;
}
inline void write(long long x) {
  long long y(10), len(1);
  while (y <= x) y = (y << 1) + (y << 3), len++;
  while (len--) {
    y /= 10;
    putchar(x / y + 48);
    x %= y;
  }
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
template <class T>
T Min(T x, T y) {
  return (x) < (y) ? (x) : (y);
}
template <class T>
T Max(T x, T y) {
  return (x) < (y) ? (y) : (x);
}
}  // namespace Fastio
using namespace Fastio;
string s[3];
long long a[3][100010], b[3][100010], ans = 0x3f3f3f3f;
long long base = 131, Mod = 100000007;
long long bas[100010], vis[3] = {0};
void solve(long long id) {
  long long len = s[id].size();
  for (long long i = 0; i < len; i++)
    a[id][i] = ((i > 0) * a[id][i - 1] + s[id][i] * bas[i]) % Mod;
  for (long long i = len - 1; i >= 0; i--)
    b[id][i] = (b[id][i + 1] + s[id][i] * bas[i]) % Mod;
}
bool check_in(long long id1, long long id2) {
  long long len1 = s[id1].size(), len2 = s[id2].size();
  long long h1 = a[id1][len1 - 1], h2 = a[id2][len1 - 1];
  if (h1 == h2) return 1;
  for (long long i = len1; i < len2; i++) {
    h2 = (a[id2][i] - a[id2][i - len1] + Mod) % Mod;
    h1 = h1 * base % Mod;
    if (h1 == h2) return 1;
  }
  return 0;
}
long long getlen(long long id1, long long id2) {
  long long ans = 0, len1 = s[id1].size(), len2 = s[id2].size();
  for (long long i = 1; i < min(len1, len2); i++)
    if (b[id1][len1 - i] == (a[id2][i - 1] * bas[len1 - i] % Mod))
      ans = max(ans, i);
  return ans;
}
long long work(long long id1, long long id2, long long id3) {
  if (vis[id1]) {
    if (vis[id2]) return s[id3].size();
    if (vis[id3]) return s[id2].size();
    return s[id2].size() + s[id3].size() - getlen(id2, id3);
  }
  if (vis[id2]) {
    if (vis[id1]) return s[id3].size();
    if (vis[id3]) return s[id1].size();
    return s[id1].size() + s[id3].size() - getlen(id1, id3);
  }
  if (vis[id3]) {
    if (vis[id1]) return s[id2].size();
    if (vis[id2]) return s[id1].size();
    return s[id1].size() + s[id2].size() - getlen(id1, id2);
  }
  return s[id1].size() + s[id2].size() + s[id3].size() - getlen(id1, id2) -
         getlen(id2, id3);
}
int main() {
  cin >> s[0] >> s[1] >> s[2];
  if (s[1].size() < s[0].size()) swap(s[0], s[1]);
  if (s[2].size() < s[1].size()) swap(s[1], s[2]);
  if (s[1].size() < s[0].size()) swap(s[0], s[1]);
  long long maxlen = s[2].size();
  bas[0] = 1;
  for (long long i = 1; i <= maxlen; i++) bas[i] = (bas[i - 1] * base) % Mod;
  for (long long i = 0; i < 3; i++) solve(i);
  if (check_in(0, 1)) vis[0] = 1;
  if (check_in(0, 2)) vis[0] = 1;
  if (check_in(1, 2)) vis[1] = 1;
  for (long long x = 0; x < 3; x++)
    for (long long y = 0; y < 3; y++)
      for (long long z = 0; z < 3; z++)
        if (x != y && y != z && x != z) ans = min(ans, work(x, y, z));
  cout << ans;
  return 0;
}
