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 = 'import sys\ninput = sys.stdin.readline\n\nS = list(input().rstrip())\nL = len(S)\n\n# binary indexed tree\nbit = [0 for _ in range(L+1)]\n\n# 0からiまでの区間和\n# 立っているビットを下から処理\ndef query_sum(i):\n    s = 0\n    while i > 0:\n        s += bit[i]\n        i -= i & -i\n    return s\n\n# i番目の要素にxを足す\n# 覆ってる区間すべてに足す\ndef add(i, x):\n    while i <= L:\n        bit[i] += x\n        i += i & -i\n\ndef main():\n    A = {}\n    for i, s in enumerate(S):\n        if not s in A.keys():\n            A[s] = [i]\n        else:\n            A[s].append(i)\n    odd = 0\n    dic = {}\n    for al, c in A.items():\n        dic[al] = 0\n        if len(c)%2 != 0:\n            odd += 1\n    if odd > 1:\n        print(-1)\n    else:\n        make_ind = []\n        for s, B in A.items():\n            l = len(B)\n            if l%2 == 1:\n                mid = B[l//2]\n            for j, b in enumerate(B):\n                if j < l//2:\n                    make_ind.append(b)\n        make_ind.sort()\n        IND = [None]*L\n        for i, m in enumerate(make_ind):\n            s = S[m]\n            IND[m] = i+1\n            inv = A[s][len(A[s])-1-dic[s]]\n            IND[inv] = L-i\n            dic[s] += 1\n        if L%2 == 1:\n            IND[mid] = L//2+1\n        \n\n        ans = 0\n        for j, a in enumerate(IND):\n            ans += j - query_sum(a)\n            add(a, 1)\n        \n        print(ans)\n\ndef __starting_point():\n    main()\n__starting_point()'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13007