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 = 'class segment_tree_dual:\n    def __init__(self, N, compose, funcval, ID_M=None):\n        self.compose = compose\n        self.ID_M = ID_M\n        self.funcval = funcval\n\n        self.height = (N-1).bit_length() #木の段数\n        self.N0 = 1<<self.height #木の横幅 >= N\n        self.laz = [self.ID_M]*(2*self.N0) #作用素の木\n        self.val = None #値の配列\n\n    #初期値の配列を作る\n    def build(self,initial):\n        self.val = initial[:]\n\n    #laz[k] を子に伝える、k が一番下の場合は laz[k] を val に反映する\n    def propagate(self,k):\n        if self.laz[k] == self.ID_M: return;\n        if self.N0 <= k:\n            self.val[k-self.N0] = self.funcval(self.val[k-self.N0], self.laz[k])\n            self.laz[k] = self.ID_M\n        else:\n            self.laz[(k<<1)  ] = self.compose(self.laz[(k<<1)  ],self.laz[k]);\n            self.laz[(k<<1)+1] = self.compose(self.laz[(k<<1)+1],self.laz[k]);\n            self.laz[k] = self.ID_M;\n    \n    # 遅延をすべて解消する\n    def propagate_all(self):\n        upto = self.N0 + len(self.val)\n        for i in range(1,upto): self.propagate(i)\n\n    # laz[k]およびその上に位置する作用素をすべて伝播\n    def thrust(self,k):\n        for i in range(self.height,-1,-1): self.propagate(k>>i)\n\n    # 区間[l,r]に関数 f を作用\n    def update(self, L,R,f):\n        L += self.N0; R += self.N0+1\n        """まず伝播させる（オペレータが可換なら必要ない）"""\n        #self.thrust(L)\n        #self.thrust(R-1)\n        #登りながら関数 f を合成\n        while L < R:\n            if R & 1:\n                R -= 1\n                self.laz[R] = self.compose(self.laz[R],f)\n            if L & 1:\n                self.laz[L] = self.compose(self.laz[L],f)\n                L += 1\n            L >>= 1; R >>= 1\n    \n    # values[k] を取得。\n    def point_get(self, k):\n        res = self.val[k]\n        k += self.N0\n        while k:\n            if self.laz[k] != self.ID_M:\n                res = self.funcval(res, self.laz[k])\n            k //= 2\n        return res\n    \n    # values[k] = x 代入する\n    def point_set(self, k): \n        self.thrust(k+self.N0)\n        self.val[k] = x\n\n\n\n# coding: utf-8\n# Your code here!\nimport sys\nreadline = sys.stdin.readline\nread = sys.stdin.read\n\n#x,y = map(int,readline().split())\nfrom collections import deque\ns = input()\nlst = [deque() for _ in range(26)]\nfor i,c in enumerate(s):\n    lst[ord(c)-97].append(i)\n\nc = 0\nfor l in lst:\n    if len(l)%2==1: c += 1\nif c >= 2:\n    print((-1))\n    return\n\nn = len(s)\nL = 0\nR = n-1\nfrom operator import add\nseg = segment_tree_dual(n, compose=add, funcval=add, ID_M=0)\nseg.build([0]*n)\n\nans = 0\nINF = 1<<30\nfor i in range(n//2):\n    I = -1\n    v = INF\n    for idx in range(26):\n        if lst[idx]:\n            a,b = lst[idx][0], lst[idx][-1]\n            d = a+seg.point_get(a)-i + n-1-i-(b+seg.point_get(b))\n            #print(i,d,lst[idx],a+seg.point_get(a),(b+seg.point_get(b)))\n            if d < v:\n                I = idx\n                v = d\n    #print(v,I,lst[I],a,seg.point_get(a),n-1,(b+seg.point_get(b)))\n    seg.update(0,lst[I].popleft(),1)\n    seg.update(lst[I].pop(),n-1,-1)\n    ans += v\n\nprint(ans)\n\n\n\n\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: