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 defaultdict, deque\nfrom heapq import heappop, heappush\nfrom string import ascii_lowercase as abc\n\nclass BIT:\n    def __init__(self, N):\n        # Nは入れたい要素の個数\n        self.size = 2 ** (int.bit_length(N+1))\n        self.tree = [0]*(self.size + 1)\n \n    def sum(self, i):\n        res = 0\n        while i:\n            res += self.tree[i]\n            i -= (i & -(i))\n        return res\n \n    def add(self, i, x):\n        if i == 0:\n            return\n        while i <= self.size:\n            self.tree[i] += x\n            i += (i & -(i))\n\n\nD = [deque() for _ in range(26)]\nS = input()\nN = len(S)\n\nfor i in range(len(S)):\n    D[ord(S[i])-97].append(i)\n\nM = [len(D[i])%2 for i in range(26)]\nif sum(M) >= 2:\n    print(-1)\n    return\n\nodd = sum(M)\n\nQ = []\nfor c in range(26):\n    if len(D[c]) >= 2:\n        l = D[c].popleft()\n        r = D[c].pop()\n        a = l * 1\n        b = N - 1 - r\n        if b < a:\n            a, b = b, a\n        heappush(Q, (a, b, l, r, c))\n\nT = [0]*(N//2)\nfor i in range(N//2):\n    _, _, l, r, c = heappop(Q)\n    T[i] = c\n\n    if len(D[c]) >= 2:\n        l = D[c].popleft()\n        r = D[c].pop()\n        a = l * 1\n        b = N - 1 - r\n        if b < a:\n            a, b = b, a\n        heappush(Q, (a, b, l, r, c))\n\nL = [[] for i in range(26)]\n\nfor i in range(N//2):\n    L[T[i]].append(N-1-i)\n\nif odd:\n    L[M.index(1)].append(N//2)\n\nfor i in range(N//2-1, -1, -1):\n    L[T[i]].append(i)\n\nbit = BIT(N)\nans = 0\nfor i in range(N):\n    j = L[ord(S[i]) - 97].pop()\n    ans += i - bit.sum(j+1)\n    bit.add(j+1, 1)\nprint(ans)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: