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 = '"""\n回文の左半分の文字列たちを操作する。\n左半分の各文字に対して、本来あるべき場所(Index)を定義する。\nあとは、左半分の文字\n\n"""\n\nfrom collections import Counter\nclass BIT:\n    def __init__(self, n):\n        self.size = n\n        self.tree = [0] * (n + 1)\n\n    def sum(self, i):  # 1-index\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):  # 1-index\n        while i <= self.size:\n            self.tree[i] += x\n            i += i & -i\n\nS = input()\nN = len(S)\ncount = Counter(S)\n\n#奇数個ある文字が複数存在していないかチェック\nflag = False\nfor v in list(count.values()):\n    if v%2 == 1:\n        if flag:\n            print((-1))\n            return\n        else:\n            flag = True\n\n# 各文字が属すべきインデックスを求める\n# memo[i] -> S[i]の回文変換後のインデックス(0-indexed)\nmemo = [None]*(N)\n#appearCnt[k] -> 文字kの出現回数\nappearCnt = {k:0 for k in list(count.keys())}\n\n# まず、回文時に左半分に属する文字に関して、インデックスを割り当てる。\ntInd = 0\nfor i in range(N):\n    s = S[i]\n    if appearCnt[s] <= count[s]//2 - 1:\n        appearCnt[s] += 1\n        memo[i] = tInd\n        tInd += 1\n\n#奇数個ある文字がある場合は、真ん中になる文字に関して、インデックスを割り当てる\nif flag:\n    for i in range(N):\n        s = S[i]\n        if count[s]%2 == 1 and memo[i]==None:\n            memo[i] = tInd\n            break\n\n#回文時に右半分になる文字にインデックスを割り当てる。\n#まず、各文字の文字列Sにおける出現回数をまとめる\nappearIdx = {k:[] for k in list(count.keys())}\nfor i in range(N):\n    s = S[i]\n    appearIdx[s].append(i)\n\nfor v in list(appearIdx.values()):\n    for i in range(len(v)//2):\n        l = v[i]\n        r = v[len(v)-i-1]\n        memo[r] = (N-1)-memo[l]\nans = 0\nbit = BIT(N)\nfor i in range(N):\n    bit.add(memo[i]+1,1)\n    ans += bit.sum(N)-bit.sum(memo[i]+1)\nprint(ans)\n\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: