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 = 'import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep="\\n")\n\nclass BitSum:\n    def __init__(self, n):\n        self.n = n + 3\n        self.table = [0] * (self.n + 1)\n\n    def update(self, i, x):\n        i += 1\n        while i <= self.n:\n            self.table[i] += x\n            i += i & -i\n\n    def sum(self, i):\n        i += 1\n        res = 0\n        while i > 0:\n            res += self.table[i]\n            i -= i & -i\n        return res\n\ndef InversionNumber(lst):\n    bit = BitSum(max(lst))\n    res = 0\n    for i, a in enumerate(lst):\n        res += i - bit.sum(a)\n        bit.update(a, 1)\n    return res\n\ndef main():\n    s = input()\n    n = len(s)\n    ord_a = ord("a")\n    cnts = [0] * 26\n    s_code = []\n    flag_odd = False\n    for c in s:\n        code = ord(c) - ord_a\n        s_code.append(code)\n        cnts[code] += 1\n    odd_code = -1\n    for code, cnt in enumerate(cnts):\n        if cnt % 2 == 1:\n            if flag_odd:\n                print(-1)\n                return\n            else:\n                odd_code = code\n                flag_odd = True\n        cnts[code] = cnt // 2\n    tois = [[] for _ in range(26)]\n    to_sort_idx = []\n    new_idx = 1\n    for code in s_code:\n        if cnts[code] > 0:\n            to_sort_idx.append(new_idx)\n            tois[code].append(n + 1 - new_idx)\n            cnts[code] -= 1\n            new_idx += 1\n        else:\n            if flag_odd and code == odd_code:\n                to_sort_idx.append(n // 2 + 1)\n                flag_odd = False\n            else:\n                to_sort_idx.append(tois[code].pop())\n    # print(to_sort_idx)\n    print(InversionNumber(to_sort_idx))\n\nmain()\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 17689