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 Counter\nS = input()\nN = len(S)\nctr = Counter(S)\nif len([1 for v in ctr.values() if v%2]) > 1:\n    print(-1)\n    return\n\nM = None\nfor k,v in ctr.items():\n    if v%2:\n        M = k\n    ctr[k] //= 2\n\ndef ctoi(c):\n    return ord(c) - ord('a')\nfrom collections import deque\nidxs = [deque() for _ in range(26)]\nfor i,c in enumerate(S):\n    idxs[ctoi(c)].append(i)\n\nA = ''\nP = []\ni = 0\nwhile len(A) < N//2:\n    c = S[i]\n    if ctr[c] > 0:\n        ctr[c] -= 1\n        A += c\n        P.append(idxs[ctoi(c)].popleft())\n    i += 1\nif M:\n    P.append(idxs[ctoi(M)].popleft())\nfor c in A[::-1]:\n    P.append(idxs[ctoi(c)].popleft())\n\ndef inversion(inds):\n    bit = [0] * (N+1)\n    def bit_add(x,w):\n        while x <= N:\n            bit[x] += w\n            x += (x & -x)\n    def bit_sum(x):\n        ret = 0\n        while x > 0:\n            ret += bit[x]\n            x -= (x & -x)\n        return ret\n    inv = 0\n    for ind in reversed(inds):\n        inv += bit_sum(ind + 1)\n        bit_add(ind + 1, 1)\n    return inv\n\nprint(inversion(P))"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: