output_description: If the objective is achievable, print the number of operations required. If it
  is not, print `-1` instead.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      s
attempt: import sys
  
  input = sys.stdin.readline
  
  
  def read():
      S = input().strip()
      return (S,)
  
  
  def is_palindrome(seq):
      n = len(seq)
      for i in range(n // 2):
          if seq[i] != seq[n - i - 1]:
              return False
      return True
  
  
  def solve(S):
      S = "*" + S + "*"
      T = [a for a in S if a != "x"]
      N = len(T) // 2 + len(T) % 2
      if not is_palindrome(T):
          return -1
      l = 0
      r = len(S) - 1
      c = 0
      while c < N:
          if S[l] != "x":
              c += 1
          l += 1
      c = 0
      while c < N:
          if S[r] != "x":
              c += 1
          r -= 1
  
      L = S[:l]
      R = S[r + 1 :][::-1]
      ans = 0
      l, r = 0, 0
      for i in range(N + 1):
          lc = 0
          rc = 0
          while l < len(L) and L[l] == "x":
              lc += 1
              l += 1
          while r < len(R) and R[r] == "x":
              rc += 1
              r += 1
          ans += abs(lc - rc)
          l += 1
          r += 1
      return ans
  
  
  if __name__ == "__main__":
      inputs = read()
      print(solve(*inputs))
  
problem_description: Statement
  
  We have a string s consisting of lowercase English letters. Snuke can perform
  the following operation repeatedly:
  
    * Insert a letter `x` to any position in s of his choice, including the beginning and end of s.
  
  Snuke's objective is to turn s into a palindrome. Determine whether the
  objective is achievable. If it is achievable, find the minimum number of
  operations required.
samples: [{"input": "xabxa", "output": "2\n    \n\nOne solution is as follows (newly inserted `x` are shown in bold):\n\nxabxa \u2192 xa**x** bxa \u2192 xaxbxa**x**\n\n* * *"}, {"input": "ab", "output": "-1\n    \n\nNo sequence of operations can turn s into a palindrome.\n\n* * *"}, {"input": "a", "output": "0\n    \n\ns is a palindrome already at the beginning.\n\n* * *"}, {"input": "oxxx", "output": "3\n    \n\nOne solution is as follows:\n\noxxx \u2192 **x** oxxx \u2192 **x** xoxxx \u2192 **x** xxoxxx"}]