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 = 'from collections import deque\nimport copy\nclass BIT:\n    def __init__(self, node_size):\n        self._node = node_size+1\n        self.bit = [0]*self._node\n \n    def add(self, index, add_val):\n        while index < self._node:\n            self.bit[index] += add_val\n            index += index & -index\n \n    def sum(self, index):\n        res = 0\n        while index > 0:\n            res += self.bit[index]\n            index -= index & -index\n        return res\n \ns = input()\nn = len(s)\na = [ord(i) - ord("a") for i in s]\nx = [0]*26\nfor i in a:\n  x[i] += 1\nflag = 1\nki = -1\nfor i in x:\n  if i%2 == 1:\n    if flag:\n      flag = 0\n    else:\n      print(-1)\n      return\nc = []\nx2 = [0]*26\nfor i in a:\n  x2[i] += 1\n  if x[i]//2 >= x2[i]:\n    c.append(i)\nfor i in range(26):\n  if x[i]%2 == 1:\n    b = copy.deepcopy(c)\n    c.append(i)\n    b = b[::-1]\n    c.extend(b)\n    break\nelse:\n  b = copy.deepcopy(c)\n  b = b[::-1]\n  c.extend(b) \nd = {}\nfor i in range(26):\n  d[i] = deque([])\nfor i in range(n):\n  d[c[i]].append(i+1)\nfor i in range(n):\n  x = d[a[i]].popleft()\n  a[i] = x\nb = []\nfor i in range(n):\n  b.append([a[i],i+1])\nb.sort()\nb = b[::-1]\nbit = BIT(n)\nans = 0\nfor i,j in b:\n  bit.add(j,1)\n  ans += bit.sum(j-1)\nprint(ans)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: