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 f(x):\n    return ord(x)-ord("a")\n\nclass Bit:\n    def __init__(self, n):\n        self.n = n\n        self.tree = [0]*(n+1)\n        self.el = [0]*(n+1)\n        self.depth = n.bit_length() - 1\n\n    def sum(self, i):\n        """ 区間[0,i) の総和を求める """\n        s = 0\n        i -= 1\n        while i >= 0:\n            s += self.tree[i]\n            i = (i & (i + 1) )- 1\n        return s\n\n    def add(self, i, x):\n        self.el[i] += x\n        while i < self.n:\n            self.tree[i] += x\n            i |= i + 1\n\nclass BitSet2:\n    """ 座標圧縮が必要な場合 """\n    def __init__(self, data, A=[]):\n        """ BitSetに入り得る値を先読みした物を data に格納 """\n        self.data = sorted(list(set(data)))\n        self.n = len(self.data)\n        self.p = Bit(self.n + 1)\n        self.size = 0\n        self.flip = 0\n        self.code = {}\n        self.decode = {}\n        for i, b in enumerate(self.data):\n            self.code[b] = i\n            self.decode[i] = b\n        for a in A:\n            self.add(a)\n\n    def add(self,x):\n        self.p.add(self.code[x], 1)\n        self.size += 1\n        self.flip += self.size - self.p.sum(self.code[x]+1)\n\n    def remove(self,x):\n        self.p.add(x, -1)\n        self.size -= 1\n\n    def flip_counter(self):\n        return self.flip\n\n####################################################################################################\n\nimport sys\ninput = sys.stdin.readline\n\nS=input().rstrip()\nN=len(S)\nP=[[] for _ in range(26)]\nQ=[]\nres=[-1]*N\nfor i, s in enumerate(S):\n    P[f(s)].append(i)\nfor p in P:\n    Np=len(p)\n    for i in range(Np//2):\n        Q.append((p[Np-1-i]-p[i],p[i],p[Np-1-i]))\n    if len(p)%2:\n        if res[N//2]!=-1 or N%2==0: print(-1); return\n        res[N//2]=p[Np//2]\nQ.sort(reverse=True)\nfor i,q in enumerate(Q):\n    d,x,y=q\n    res[i]=x\n    res[N-1-i]=y\n\nBS = BitSet2(res,res)\nprint(BS.flip_counter())'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: