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\n\n\nclass BIT():\n    """一点加算、区間取得クエリをそれぞれO(logN)で答える\n    add: i番目にvalを加える\n    get_sum: 区間[l, r)の和を求める\n    i, l, rは0-indexed\n    """\n    def __init__(self, n):\n        self.n = n\n        self.bit = [0] * (n + 1)\n\n    def _sum(self, i):\n        s = 0\n        while i > 0:\n            s += self.bit[i]\n            i -= i & -i\n        return s\n\n    def add(self, i, val):\n        """i番目にvalを加える"""\n        i = i + 1\n        while i <= self.n:\n            self.bit[i] += val\n            i += i & -i\n\n    def get_sum(self, l, r):\n        """区間[l, r)の和を求める"""\n        return self._sum(r) - self._sum(l)\n\n\ndef min_swap_times(s, t):\n    if Counter(s) != Counter(t):\n        return -1\n\n    n = len(s)\n    memo = {}\n    for i in range(n):\n        if s[i] not in memo:\n            memo[s[i]] = [i]\n        else:\n            memo[s[i]].append(i)\n    for i in memo:\n        memo[i] = memo[i][::-1]\n\n    array = [0] * n\n    for i in range(n):\n        array[i] = memo[t[i]][-1]\n        del(memo[t[i]][-1])    \n\n    memo = {}\n    for i in range(n):\n        memo[i] = array[i]\n    bit = BIT(n)\n    res = 0\n\n    for i in range(n):\n        bit.add(memo[i], 1)\n        res += bit.get_sum(memo[i] + 1, n)\n    return res\n\n\nimport copy\n\ns = input()\nn = len(s)\nmemo = {}\nfor i in range(n):\n    if s[i] not in memo:\n        memo[s[i]] = 1\n    else:\n        memo[s[i]] += 1\n\nodd_cnt = 0\nfor i in memo:\n    odd_cnt += memo[i] % 2\nif odd_cnt > 1:\n    print(-1)\n    return\n\nleft = []\nright = []\n\nmemo2 = copy.deepcopy(memo)\nans_cnt = 0\nword = ""\nfor i in range(n):\n    if memo2[s[i]]*2 > memo[s[i]] + 1:\n        memo2[s[i]] -= 1\n        ans_cnt += i - len(left)\n        left.append(s[i])\n    elif memo2[s[i]]*2 == memo[s[i]] + 1:\n        word = s[i]\n        memo2[s[i]] -= 1\n        right.append(s[i])\n    else:\n        memo2[s[i]] -= 1\n        right.append(s[i])\n \nif word != "":\n    for i in range(len(right)):\n        if right[i] == word:\n            ans_cnt += i\n            del(right[i])\n            break\nright = right[::-1]\ntmp = min_swap_times(left, right)\nif tmp == -1:\n    print(-1)\nelse:\n    print(ans_cnt + tmp)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: