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\ndef input():\n\treturn sys.stdin.readline()[:-1]\n\nclass BIT():#1-indexed\n\tdef __init__(self, size):\n\t\tself.table = [0 for _ in range(size+2)]\n\t\tself.size = size\n\n\tdef Sum(self, i):#1からiまでの和\n\t\ts = 0\n\t\twhile i > 0:\n\t\t\ts += self.table[i]\n\t\t\ti -= (i & -i)\n\t\treturn s\n\n\tdef PointAdd(self, i, x):#\n\t\twhile i <= self.size:\n\t\t\tself.table[i] += x\n\t\t\ti += (i & -i)\n\t\treturn\n\ns = input()\nn = len(s)\na = [-1 for _ in range(n)]\nch = [[] for _ in range(26)]\nfor i in range(n):\n\tch[ord(s[i])-97].append(i)\nif sum([len(x)%2 == 1 for x in ch]) > 1:\n\tprint(-1)\n\treturn\n\nfor i, c in enumerate(ch):\n\ttmp = i\n\tl = len(c)\n\tfor j in range(l//2):\n\t\ta[c[j]] = tmp\n\t\ta[c[l-j-1]] = tmp\n\t\ttmp += 26\n#print(a)\n\nformer, latter = 0, 0\nhalf = False\nd = dict()\ncur = 0\nbubble = []\n\nans = 0\n\nfor x in a:\n\tif x >= 0:\n\t\tif x not in d:\n\t\t\td[x] = cur\n\t\t\tcur += 1\n\t\t\tformer += 1\n\t\t\tans += latter + half\n\t\telse:\n\t\t\tbubble.append(d[x])\n\t\t\tlatter += 1\n\t\t\tif n%2 == 1 and not half:\n\t\t\t\tans += 1\n\telse:\n\t\thalf = True\n\nbit = BIT(n//2+2)\nfor b in bubble:\n\tans += bit.Sum(b+1)\n\tbit.PointAdd(b+1, 1)\n\nprint(ans)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: