output_description: Print the minimum possible length of s.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      a
      b
      c
attempt: # coding: utf-8
  # Your code here!
  # coding: utf-8
  import sys
  
  sys.setrecursionlimit(10000000)
  
  
  # const
  # my functions here!
  def pin(type=int):
      return map(type, input().rstrip().split())
  
  
  """
  def resolve():
      a,b,c=pin()
      from math import sqrt
      cond =(c-a-b)>sqrt(a*b)*2
      print(["No","Yes"][cond])
  """
  
  
  def resolve():
      t = [input() for i in range(3)]
      ans = sum(map(lambda x: len(x), t))  # デフォ値
  
      from itertools import permutations as p
  
      for perm in p(range(3)):
          x, y, z = t[perm[0]], t[perm[1]], t[perm[2]]
          X, Y, Z = len(x), len(y), len(z)
          kasa = [0, 0]
  
          # xy
  
          for ixy in range(min(X, Y), -1, -1):
              # ixyはxのケツとyの頭での文字の重なり（?をふくむ
              # 重なりの最大を求めたいのでrev
              # print("ya")
              # ixy個の文字比較
              flag = 0
              for pxy in range(ixy):
                  # print(x,y,ixy)
                  # print(y[pxy],x[X-ixy+pxy],(y[pxy]==x[X-ixy+pxy]))
                  if y[pxy] != "?" and x[X - ixy + pxy] != "?":
                      if y[pxy] != x[X - ixy + pxy]:
                          flag = 1
                          break
              if flag == 1:
                  continue
              if flag == 0:
                  # print("end")
                  kasa[0] = ixy
                  break
              flag = 0
          # yz
  
          for iyz in range(min(Z, Y), -1, -1):
              # ixyはxのケツとyの頭での文字の重なり（?をふくむ
              # 重なりの最大を求めたいのでrev
  
              # ixy個の文字比較
              flag2 = 0
              for pyz in range(iyz):
                  if z[pyz] != "?" and y[Y - iyz + pyz] != "?":
                      if z[pyz] != y[Y - iyz + pyz]:
                          flag2 = 1
                          break
              if flag == 1:
                  continue
              if flag2 == 0:
                  kasa[1] = iyz
                  break
              flag2 = 0
          # print(kasa)
          ans = min(ans, X + Y + Z - sum(kasa))
      print(ans)
  
  
  """         
  #printデバッグ消した？
  #前の問題の結果見てないのに次の問題に行くの？
  """
  """
  お前カッコ閉じるの忘れてるだろ
  """
  import sys
  from io import StringIO
  import unittest
  
  
  class TestClass(unittest.TestCase):
      def assertIO(self, input, output):
          stdout, stdin = sys.stdout, sys.stdin
          sys.stdout, sys.stdin = StringIO(), StringIO(input)
          resolve()
          sys.stdout.seek(0)
          out = sys.stdout.read()[:-1]
          sys.stdout, sys.stdin = stdout, stdin
          self.assertEqual(out, output)
  
      def test_入力例_1(self):
          input = """a?c
  der
  cod"""
          output = """7"""
          self.assertIO(input, output)
  
      def test_入力例_2(self):
          input = """atcoder
  atcoder
  ???????"""
          output = """7"""
          self.assertIO(input, output)
  
  
  if __name__ == "__main__":
      resolve()
  
problem_description: Statement
  
  Snuke has a string s. From this string, Anuke, Bnuke, and Cnuke obtained
  strings a, b, and c, respectively, as follows:
  
    * Choose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with `?`s.
  
  For example, if s is `mississippi`, we can choose the substring `ssissip` and
  replace its 1-st and 3-rd characters with `?` to obtain `?s?ssip`.
  
  You are given the strings a, b, and c. Find the minimum possible length of s.
samples: [{"input": "a?c\n    der\n    cod", "output": "7\n    \n\nFor example, s could be `atcoder`.\n\n* * *"}, {"input": "atcoder\n    atcoder\n    ???????", "output": "7\n    \n\na, b, and c may not be distinct."}]