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 main():\n    from collections import deque\n\n    # 一点更新・一点取得の加法BIT\n    class BIT():\n        def __init__(self, n):\n            self.n = n\n            self.maxbit = 2**(len(bin(n))-3)\n            self.bit = [0]*(n+1)\n            self.allsum = 0\n\n        # 初期化する\n        def make_bit(self, a):\n            n, bit = self.n, self.bit\n            for i, j in enumerate(a):\n                x = i+1\n                self.allsum += j\n                while x < n+1:\n                    bit[x] += j\n                    x += x & (-x)\n\n        # 位置iに値vを足す\n        def add(self, i, v):\n            x, n, bit = i+1, self.n, self.bit\n            self.allsum += v\n            while x < n+1:\n                bit[x] += v\n                x += x & (-x)\n\n        # 位置0からiまでの和(sum(bit[:i]))を計算する\n        def sum(self, i):\n            ret, x, bit = 0, i, self.bit\n            while x > 0:\n                ret += bit[x]\n                x -= x & (-x)\n            return ret\n\n        # 位置iからjまでの和(sum(bit[i:j]))を計算する\n        def sum_range(self, i, j):\n            return self.sum(j) - self.sum(i)\n\n        # 和がw以上となる最小のインデックスを求める\n        def lowerbound(self, w):\n            if w <= 0:\n                return 0\n            x, k, n, bit = 0, self.maxbit, self.n, self.bit\n            while k:\n                if x+k <= n and bit[x+k] < w:\n                    w -= bit[x+k]\n                    x += k\n                k //= 2\n            return x\n\n    s = input()\n    n = len(s)\n    alpha, center = \'abcdefghijklmnopqrstuvwxyz\', ""\n    counter, must, deque_dict = dict(), dict(), dict()\n    for c in alpha:\n        counter[c] = 0\n        deque_dict[c] = deque([])\n    for c in s:\n        counter[c] += 1\n    for i, j in list(counter.items()):\n        must[i] = j//2\n    if n % 2 == 1:\n        for i, j in list(counter.items()):\n            if j % 2 == 1:\n                if center != "":\n                    print((-1))\n                    return 0\n                else:\n                    center = i\n    else:\n        for i, j in list(counter.items()):\n            if j % 2 == 1:\n                print((-1))\n                return 0\n    half = []\n    cnt = 0\n    for c in s:\n        if must[c] > 0:\n            must[c] -= 1\n            half.append(c)\n            cnt += 1\n        if cnt == n//2:\n            break\n    half2 = half[::-1]\n    if center != "":\n        half.append(center)\n    s2 = half+half2\n\n    for i in range(n):\n        deque_dict[s[i]].append(i)\n\n    ans = 0\n    s3 = []\n    for c in s2:\n        d = deque_dict[c].popleft()\n        s3.append(d)\n\n    bit = BIT(n)\n\n    for i in s3:\n        ans += bit.sum_range(i, n)\n        bit.add(i, 1)\n    print(ans)\n\n\nmain()\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 35997