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: def inner(a, b, la, lb):
      for i in range(lb - la + 1):
          for j in range(la):
              if a[j] == "?" or a[j] == b[i + j]:
                  continue
              elif b[i + j] == "?":
                  continue
              else:
                  break
          else:
              return True
      return False
  
  
  def head(a, b, la):
      for i in range(la, -1, -1):
          for j in range(i):
              if a[j] == "?" or a[j] == b[-(i - j)]:
                  continue
              elif b[-(i - j)] == "?":
                  continue
              else:
                  break
          else:
              return b + a[i:]
  
  
  def tail(a, b, la):
      for i in range(la, -1, -1):
          for j in range(i):
              if a[-(i - j)] == "?" or a[-(i - j)] == b[j]:
                  continue
              elif b[j] == "?":
                  continue
              else:
                  break
          else:
              return a + b[i:]
              break
  
  
  a = input()
  la = len(a)
  b = input()
  lb = len(b)
  c = input()
  lc = len(c)
  arr = [[a, la], [b, lb], [c, lc]]
  arr = sorted(arr, key=lambda x: x[1])
  a, la = arr[0]
  b, lb = arr[1]
  c, lc = arr[2]
  tmp1 = head(a, c, la)
  tmp2 = tail(a, c, la)
  ans1 = min(len(head(b, tmp1, lb)), len(tail(b, tmp1, lb)))
  if inner(b, tmp1, lb, len(tmp1)):
      ans1 = min(ans1, len(tmp1))
  ans2 = min(len(head(b, tmp2, lb)), len(tail(b, tmp2, lb)))
  if inner(b, tmp2, lb, len(tmp2)):
      ans2 = min(ans2, len(tmp2))
  ans3 = 10**18
  if inner(a, c, la, lc):
      ans3 = min(len(head(b, c, lb)), len(tail(b, c, lb)))
      if inner(b, c, lb, lc):
          ans3 = min(ans3, lc)
  ansac = min(ans1, ans2, ans3)
  tmp1 = head(b, c, lb)
  tmp2 = tail(b, c, lb)
  ans1 = min(len(head(a, tmp1, la)), len(tail(a, tmp1, la)))
  if inner(a, tmp1, la, len(tmp1)):
      ans1 = min(ans1, len(tmp1))
  ans2 = min(len(head(a, tmp2, la)), len(tail(a, tmp2, la)))
  if inner(a, tmp2, la, len(tmp2)):
      ans2 = min(ans2, len(tmp2))
  ans3 = 10**18
  if inner(b, c, lb, lc):
      ans3 = min(len(head(a, c, la)), len(tail(a, c, la)))
      if inner(a, c, la, lc):
          ans3 = min(ans3, lc)
  ansbc = min(ans1, ans2, ans3)
  tmp1 = head(a, b, la)
  lt1 = len(tmp1)
  tmp2 = tail(a, b, la)
  lt2 = len(tmp2)
  if lt1 >= lc:
      ans1 = min(len(head(c, tmp1, lc)), len(tail(c, tmp1, lc)))
      if inner(c, tmp1, lc, lt1):
          ans1 = min(ans1, lt1)
  else:
      ans1 = min(len(head(tmp1, c, lt1)), len(tail(tmp1, c, lt1)))
      if inner(tmp1, c, lt1, c):
          ans1 = min(ans1, c)
  if lt2 >= lc:
      ans2 = min(len(head(c, tmp2, lc)), len(tail(c, tmp2, lc)))
      if inner(c, tmp2, lc, lt2):
          ans2 = min(ans2, lt2)
  else:
      ans2 = min(len(head(tmp2, c, lt2)), len(tail(tmp2, c, lt2)))
      if inner(tmp2, c, lt2, lc):
          ans2 = min(ans2, lc)
  ans3 = 10**18
  if inner(a, b, la, lb):
      ans3 = min(len(head(b, c, lb)), len(tail(b, c, lb)))
      if inner(b, c, lb, lc):
          ans3 = min(ans3, lc)
  ansab = min(ans1, ans2, ans3)
  ans = min(ansac, ansbc, ansab)
  print(ans)
  
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."}]