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.

-----Constraints-----
 - 1 \leq |S| \leq 2 × 10^5
 - S consists of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
If we cannot turn S into a palindrome, print -1. Otherwise, print the minimum required number of operations.

-----Sample Input-----
eel

-----Sample Output-----
1

We can turn S into a palindrome by the following operation:
 - Swap the 2-nd and 3-rd characters. S is now ele.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "def count_inversions(L):\n  def helper(A,B):\n    lA,lB = len(A),len(B)\n    if lA == 0:\n      return B,0\n    elif lB == 0:\n      return A,0\n    \n    A,c1 = helper(A[:lA//2],A[lA//2:])\n    B,c2 = helper(B[:lB//2],B[lB//2:])\n    cnt = c1+c2\n    i = 0\n    j = 0\n\n    C = [None]*(lA+lB)\n    while i < lA and j < lB:\n      if A[i] > B[j]:\n        cnt += lA-i\n        C[i+j] = B[j]\n        j += 1\n      else:\n        C[i+j] = A[i]\n        i += 1\n\n    if i < lA:\n      C[i+j:] = A[i:]\n    else:\n      C[i+j:] = B[j:]\n\n    return C,cnt\n\n  return helper(L[:len(L)//2],L[len(L)//2:])[1]\n\nfrom collections import deque\n\nALPHABETS = 26\n\nindices = [deque() for _ in range(26)]\nS = list([ord(c)-ord('a') for c in input()])\nfor i,c in enumerate(S):\n  indices[c] += [i]\n\nodd = None\nfor c,l in enumerate(indices):\n  if len(l)%2 == 1:\n    if odd is None:\n      odd = c\n    else:\n      odd = -1\n      break\n\nif odd == -1:\n  print((-1))\n  return\n\ntarget = [None]*len(S)\nassigned = [False]*len(S)\nif odd is not None:\n  l = list(indices[odd])\n  i = l[len(l)//2]\n  target[len(target)//2] = i\n  assigned[i] = True\n  l = deque(l[:len(l)//2] + l[len(l)//2+1:])\n\nj = 0\nfor i in range(len(S)//2):\n  while assigned[j]:\n    j += 1\n\n  l = indices[S[j]]\n  a = l.popleft()\n  b = l.pop()\n  assert a == j\n  target[i] = a\n  target[len(S)-i-1] = b\n  assigned[a] = True\n  assigned[b] = True\n  \nprint((count_inversions(target)))\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: