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, defaultdict\n\n\nclass Bit:\n    def __init__(self, n):\n        self.size = n\n        self.tree = [0] * (n + 1)\n\n    def sum(self, i):\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        while i <= self.size:\n            self.tree[i] += x\n            i += i & -i\n\n\nS = input()\nN = len(S)\nC = Counter(S)\nif len(S) % 2 == 0:\n    for x in list(C.values()):\n        if x % 2 == 1:\n            print((-1))\n            return\nelse:\n    cnt = 0\n    for x in list(C.values()):\n        if x % 2 == 1:\n            cnt += 1\n        if cnt > 1:\n            print((-1))\n            return\n\ncnt1 = 1\ncnt2 = (N + 1) // 2 + 1\ncnt_char = defaultdict(int)\nseq = [0] * N\nS1 = []\nS2 = []\nfor i, s in enumerate(S):\n    cnt_char[s] += 1\n    if C[s] % 2 == 1:\n        if cnt_char[s] == C[s] // 2 + 1:\n            seq[i] = N // 2 + 1\n            continue\n    if cnt_char[s] <= C[s] // 2:\n        seq[i] = cnt1\n        cnt1 += 1\n        S1.append(s)\n    else:\n        seq[i] = cnt2\n        cnt2 += 1\n        S2.append(s)\nS2.reverse()\n\nans = 0\nseq.reverse()\nbit1 = Bit(N+1)\nfor i in range(N):\n    ans += bit1.sum(seq[i])\n    bit1.add(seq[i], 1)\n\nchar2idx = defaultdict(list)\nfor i, s1 in enumerate(S1):\n    char2idx[s1].append(i+1)\nfor x in list(char2idx.keys()):\n    char2idx[x].reverse()\n\nseq_ = []\nfor i, s2 in enumerate(S2):\n    seq_.append(char2idx[s2].pop())\n\nbit2 = Bit(N+1)\nseq_.reverse()\nfor i in range(len(seq_)):\n    ans += bit2.sum(seq_[i])\n    bit2.add(seq_[i], 1)\n\nprint(ans)\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: