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 deque\nimport sys\ninput = sys.stdin.readline\n\nclass FenwickTree:\n    def __init__(self, size):\n        self.data = [0] * (size + 1)\n        self.size = size\n\n    # i is exclusive\n    def prefix_sum(self, i):\n        s = 0\n        while i > 0:\n            s += self.data[i]\n            i -= i & -i\n        return s\n\n    def add(self, i, x):\n        i += 1\n        while i <= self.size:\n            self.data[i] += x\n            i += i & -i\n\n    def lower_bound(self, x):\n        if x <= 0:\n            return 0\n        k = 1\n        while k * 2 <= self.size:\n            k *= 2\n        i = 0\n        while k > 0:\n            if i + k <= self.size and self.data[i + k] < x:\n                x -= self.data[i + k]\n                i += k\n            k //= 2\n        return i\n\n\nclass RangeFenwickTree:\n    def __init__(self, size):\n        self.bit0 = FenwickTree(size)\n        self.bit1 = FenwickTree(size)\n\n    # i is exclusive\n    def prefix_sum(self, i):\n        return self.bit0.prefix_sum(i) * (i - 1) + self.bit1.prefix_sum(i)\n\n    def add(self, l, r, x):\n        self.bit0.add(l, x)\n        self.bit0.add(r, -x)\n        self.bit1.add(l, -x * (l - 1))\n        self.bit1.add(r, x * (r - 1))\n\n\nclass FenwickTree2D:\n    def __init__(self, H, W):\n        self.H = H\n        self.W = W\n        self.data = [[0] * (H + 1) for _ in range(W + 1)]\n\n    def add(self, a, b, x):\n        a += 1\n        b += 1\n        i = a\n        while i <= self.H:\n            j = b\n            while j <= self.W:\n                self.data[i][j] += x\n                j += j & -j\n            i += i & -i\n\n    def sum(self, a, b):\n        a += 1\n        b += 1\n        ret = 0\n        i = a\n        while i > 0:\n            j = b\n            while j > 0:\n                ret += self.data[i][j]\n                j -= j & -j\n            i -= i & -i\n        return ret\n\nS = list(map(lambda c: ord(c) - ord('a'), input().rstrip()))\nN = len(S)\nidx = [deque() for _ in range(26)]\nfor i, c in enumerate(S):\n    idx[c].append(i)\nif sum(len(v) % 2 for v in idx) > 1:\n    print(-1)\n    return\nfw = FenwickTree(N + 1)\nfor i in range(1, N + 1):\n    fw.add(i, 1)\nans = 0\nfor i in range(N // 2):\n    min_cost = float('inf')\n    char = -1\n    for c in range(26):\n        if len(idx[c]) <= 1:\n            continue\n        l = idx[c][0]\n        cost = fw.prefix_sum(l + 1) - i\n        r = idx[c][-1]\n        cost += N - i - 1 - fw.prefix_sum(r + 1)\n        if cost < min_cost:\n            min_cost = cost\n            char = c\n    ans += min_cost\n    fw.add(0, 1)\n    fw.add(idx[char].popleft(), -1)\n    fw.add(idx[char].pop(), -1)\nprint(ans)"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: