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: import sys
  
  sys.setrecursionlimit(1000000)
  
  
  def js(s1, s2):
  
      for i in range(0, len(s1)):
          flag = True
          for j in range(0, min(len(s1) - i, len(s2))):
              c1 = s1[i + j]
              c2 = s2[j]
  
              if c1 != "?" and c2 != "?" and c1 != c2:
                  flag = False
                  break
  
          if flag:
              if len(s1) > len(s2) + i:
                  l1 = list(s1)
                  for j in range(len(s2)):
                      if s1[i + j] == "?":
                          l1[i + j] = s2[j]
                  return "".join(l1)
              else:
                  l2 = list(s2)
                  for j in range(i, len(s1)):
                      if s2[j - i] == "?":
                          l2[j - i] = s1[j]
                  return s1[:i] + "".join(l2)
      return s1 + s2
  
  
  def main():
      a = input()
      b = input()
      c = input()
  
      ac = js(a, c)
      ab = js(a, b)
      ba = js(b, a)
      bc = js(b, c)
      ca = js(c, a)
      cb = js(c, b)
  
      abc = js(ab, c)
      acb = js(ac, b)
      bac = js(ba, c)
      bca = js(bc, a)
      cab = js(ca, b)
      cba = js(cb, a)
  
      # for s in (abc, acb, bac, bca, cab, cba):
      #    print(s)
  
      print(min(len(s) for s in (abc, acb, bac, bca, cab, cba)))
  
  
  main()
  
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."}]