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 = 'class Bit:\n    def __init__(self, n):\n        self.size = n\n        self.tree = [0]*(n+1)\n\n    def __iter__(self):\n        psum = 0\n        for i in range(self.size):\n            csum = self.sum(i+1)\n            yield csum - psum\n            psum = csum\n        raise StopIteration()\n\n    def __str__(self):  # O(nlogn)\n        return str(list(self))\n\n    def sum(self, i):\n        # [0, i) の要素の総和を返す\n        if not (0 <= i <= self.size): raise ValueError("error!")\n        s = 0\n        while i>0:\n            s += self.tree[i]\n            i -= i & -i\n        return s\n\n    def add(self, i, x):\n        if not (0 <= i < self.size): raise ValueError("error!")\n        i += 1\n        while i <= self.size:\n            self.tree[i] += x\n            i += i & -i\n\n    def __getitem__(self, key):\n        if not (0 <= key < self.size): raise IndexError("error!")\n        return self.sum(key+1) - self.sum(key)\n\n    def __setitem__(self, key, value):\n        # 足し算と引き算にはaddを使うべき\n        if not (0 <= key < self.size): raise IndexError("error!")\n        self.add(key, value - self[key])\n\n\n\nS = input()\nN = len(S)\ncnt = [0]*26\nfor c in S:\n    cnt[ord(c)-97] += 1\nodd = -1\nfor i, cn in enumerate(cnt):\n    if cn%2 != 0:\n        if odd == -1:\n            odd = i\n        else:\n            print((-1))\n            return\n    cnt[i] //= 2\n#cnt2 = [0]*26\nL = [[] for _ in range(26)]\nn = N//2 + 1\nB = []\nfor c in S:\n    c_int = ord(c)-97\n    if cnt[c_int] == 0:\n        if c_int == odd:\n            B.append(1)\n            odd = -1\n        else:\n            p = L[c_int].pop()\n            B.append(p)\n    else:\n        L[c_int].append(n)\n        B.append(0)\n        n-=1\n        cnt[c_int] -= 1\n\nbit = Bit(N//2+2)\nans = 0\nfor i, b in enumerate(B):\n    ans += i - bit.sum(b+1)\n    bit.add(b, 1)\nprint(ans)\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: