output_description: If we cannot turn S into a palindrome, print `-1`. Otherwise, print the
  minimum required number of operations.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: S = input().strip()
  
  flips = 0
  impossible = False
  while len(S) > 1:
      ind1 = 0
      ind2 = len(S) - 1
      for i in range(len(S)):
          indi = ind2 - i
          if ind1 == indi:
              if not impossible:
                  impossible = True
                  S = S[1:]
                  break
              else:
                  print("-1")
                  exit()
          if S[ind1] == S[indi]:
              if indi == ind2:
                  S = S[1:-1]
                  break
              else:
                  S = S[1:indi] + S[indi + 1 :]
                  break
          flips += 1
  
  print(flips)
  
problem_description: Statement
  
  You are given a string S consisting of lowercase English letters. Determine
  whether we can turn S into a palindrome by repeating the operation of swapping
  two adjacent characters. If it is possible, find the minimum required number
  of operations.
samples: [{"input": "eel", "output": "1\n    \n\nWe can turn S into a palindrome by the following operation:\n\n  * Swap the 2-nd and 3-rd characters. S is now `ele`.\n\n* * *"}, {"input": "ataatmma", "output": "4\n    \n\nWe can turn S into a palindrome by the following operation:\n\n  * Swap the 5-th and 6-th characters. S is now `ataamtma`.\n  * Swap the 4-th and 5-th characters. S is now `atamatma`.\n  * Swap the 3-rd and 4-th characters. S is now `atmaatma`.\n  * Swap the 2-nd and 3-rd characters. S is now `amtaatma`.\n\n* * *"}, {"input": "snuke", "output": "-1\n    \n\nWe cannot turn S into a palindrome."}]