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 deque\nalphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\n\nS=input()\nN=len(S)\n\ndic={moji:deque([]) for moji in alphabetlist}\nfor i in range(N):\n    dic[S[i]].append(i+1)\n\nleft=deque([])\nright=deque([])\nmid=[]\n\nif N%2==1:\n    check=0\n    memo=0\n    for moji in dic:\n        if len(dic[moji])%2==1:\n            k=len(dic[moji])\n            check+=1\n            memo=dic[moji][k//2]\n    if check!=1:\n        print(-1)\n        return\n    else:\n        mid.append(memo)\nelse:\n    check=0\n    for moji in dic:\n        if len(dic[moji])%2==1:\n            print(-1)\n            return\n\nfor i in range(N//2):\n    for moji in alphabetlist:\n        if len(dic[moji])>=2:\n            L=dic[moji][0]\n            R=dic[moji][-1]\n            for moji2 in alphabetlist:\n                if len(dic[moji2])>=2 and dic[moji2][0]<L<R<dic[moji2][-1]:\n                    break\n            else:\n                left.append(L)\n                right.appendleft(R)\n                dic[moji].popleft()\n                dic[moji].pop()\n                break\n\nans=list(left)+mid+list(right)\nn=N\n#A1 ... AnのBIT(1-indexed)\nBIT = [0]*(n+1)\n\n#A1 ~ Aiまでの和 O(logN)\ndef BIT_query(idx):\n    res_sum = 0\n    while idx > 0:\n        res_sum += BIT[idx]\n        idx -= idx&(-idx)\n    return res_sum\n\n#Ai += x O(logN)\ndef BIT_update(idx,x):\n    while idx <= n:\n        BIT[idx] += x\n        idx += idx&(-idx)\n    return\n\nres=0\nfor i in range(N):\n    res+=i-BIT_query(ans[i])\n    BIT_update(ans[i],1)\n\nprint(res)"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: