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 constructable(str1, str2):
      if str1 == "?" or str2 == "?":
          return True
      elif str1 == str2:
          return True
      else:
          return False
  
  
  def condition(num):
      N = num
      if N < max(len(a), len(b), len(c)):
          return False
  
      flag = 0
      S = ["?" for i in range(0, N)]
      for i in range(0, len(a)):
          S[i] = a[i]
      for i in range(0, len(c)):
          if not constructable(S[-i - 1], c[-i - 1]):
              flag = 1
              break
          else:
              if S[-i - 1] == "?":
                  S[-i - 1] = c[-i - 1]
      if flag == 0:
          for i in range(0, N - len(b) + 1):
              start = i
              for j in range(0, len(b)):
                  if not constructable(b[j], S[start + j]):
                      break
              else:
                  return True
  
      flag = 0
      S = ["?" for i in range(0, N)]
      for i in range(0, len(a)):
          S[i] = a[i]
      for i in range(0, len(b)):
          if not constructable(S[-i - 1], b[-i - 1]):
              flag = 1
              break
          else:
              if S[-i - 1] == "?":
                  S[-i - 1] = b[-i - 1]
      if flag == 0:
          for i in range(0, N - len(c) + 1):
              start = i
              for j in range(0, len(c)):
                  if not constructable(c[j], S[start + j]):
                      break
              else:
                  return True
  
      flag = 0
      S = ["?" for i in range(0, N)]
      for i in range(0, len(b)):
          S[i] = b[i]
      for i in range(0, len(c)):
          if not constructable(S[-i - 1], c[-i - 1]):
              flag = 1
              break
          else:
              if S[-i - 1] == "?":
                  S[-i - 1] = c[-i - 1]
      if flag == 0:
          for i in range(0, N - len(a) + 1):
              start = i
              for j in range(0, len(a)):
                  if not constructable(a[j], S[start + j]):
                      break
              else:
                  return True
  
      flag = 0
      S = ["?" for i in range(0, N)]
      for i in range(0, len(b)):
          S[i] = b[i]
      for i in range(0, len(a)):
          if not constructable(S[-i - 1], a[-i - 1]):
              flag = 1
              break
          else:
              if S[-i - 1] == "?":
                  S[-i - 1] = a[-i - 1]
      if flag == 0:
          for i in range(0, N - len(c) + 1):
              start = i
              for j in range(0, len(c)):
                  if not constructable(c[j], S[start + j]):
                      break
              else:
                  return True
  
      flag = 0
      S = ["?" for i in range(0, N)]
      for i in range(0, len(c)):
          S[i] = c[i]
      for i in range(0, len(a)):
          if not constructable(S[-i - 1], a[-i - 1]):
              flag = 1
              break
          else:
              if S[-i - 1] == "?":
                  S[-i - 1] = a[-i - 1]
      if flag == 0:
          for i in range(0, N - len(b) + 1):
              start = i
              for j in range(0, len(b)):
                  if not constructable(b[j], S[start + j]):
                      break
              else:
                  return True
  
      flag = 0
      S = ["?" for i in range(0, N)]
      for i in range(0, len(c)):
          S[i] = c[i]
      for i in range(0, len(b)):
          if not constructable(S[-i - 1], b[-i - 1]):
              flag = 1
              break
          else:
              if S[-i - 1] == "?":
                  S[-i - 1] = b[-i - 1]
      if flag == 0:
          for i in range(0, N - len(a) + 1):
              start = i
              for j in range(0, len(a)):
                  if not constructable(a[j], S[start + j]):
                      break
              else:
                  return True
  
      return False
  
  
  a = input()
  b = input()
  c = input()
  s = 1
  e = 6000
  while e - s > 1:
      test = (e + s) // 2
      if condition(test):
          e = test
      else:
          s = test
  
  if condition(s):
      print(s)
  else:
      print(e)
  
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."}]