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 = '\nimport sys\nfrom collections import deque, defaultdict\nimport copy\nimport bisect\nsys.setrecursionlimit(10 ** 9)\nimport math\nimport heapq\nfrom itertools import product, permutations,combinations\nimport fractions\n\nimport sys\ndef input():\n\treturn sys.stdin.readline().strip()\n\nS = input()\n\nalpha = defaultdict(int)\nN = len(S)\nfor i in range(N):\n\talpha[S[i]] += 1\n\nnum = 0\nfor n in alpha:\n\tif alpha[n] % 2 == 1:\n\t\tnum += 1\n\nif num >= 2:\n\tprint((-1))\n\treturn\n\nalpha_num = defaultdict(deque)\nfor i in range(N):\n\talpha_num[S[i]].append(i)\n\nloc_list = [-1]*N\nnum = 0\nfor i in range(N):\n\tif len(alpha_num[S[i]]) >= 2:\n\t\tx = alpha_num[S[i]].popleft()\n\t\ty = alpha_num[S[i]].pop()\n\t\tloc_list[x] = num\n\t\tloc_list[y] = N - 1 - num\n\t\tnum += 1\n\telif len(alpha_num[S[i]]) == 1:\n\t\tx = alpha_num[S[i]].popleft()\n\t\tloc_list[x] = N // 2\n\nclass Bit:\n\tdef __init__(self, n):\n\t\tself.size = n\n\t\tself.tree = [0] * (n + 1)\n\n\tdef sum(self, i):\n\t\ts = 0\n\t\twhile i > 0:\n\t\t\ts += self.tree[i]\n\t\t\ti -= i & -i\n\t\treturn s\n\n\tdef add(self, i, x):\n\t\twhile i <= self.size:\n\t\t\tself.tree[i] += x\n\t\t\ti += i & -i\n\n\nbit = Bit(N)\nans = 0\n\n\n\nfor i, p in enumerate(loc_list):\n\tbit.add(p + 1, 1)\n\tans += i + 1 - bit.sum(p + 1)\n\nprint(ans)\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: