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 = "a2n=lambda x:ord(x)-ord('a')\n# 数値(1〜26)→アルファベット(a〜z)\nn2a = lambda x:chr(x+ord('a')).lower()\n\ns=list(map(a2n,list(input())))\nn=len(s)\ncary=[0]*26\nfrom collections import deque\nary=[deque([]) for _ in range(26)]\nfor i,x in enumerate(s):\n  cary[x]+=1\n  ary[x].append(i)\noddcnt=0\nfor x in cary:\n  if x%2==1:oddcnt+=1\nif oddcnt>1:\n  print(-1)\n  return\n\n# 0-indexed binary indexed tree\nclass BIT:\n  def __init__(self, n):\n    self.n = n\n    self.data = [0]*(n+1)\n    self.el = [0]*(n+1)\n  # sum of [0,i) sum(a[:i])\n  def sum(self, i):\n    if i==0:return 0\n    s = 0\n    while i > 0:\n      s += self.data[i]\n      i -= i & -i\n    return s\n  def add(self, i, x):\n    i+=1\n    self.el[i] += x\n    while i <= self.n:\n      self.data[i] += x\n      i += i & -i\n  # sum of [l,r)   sum(a[l:r])\n  def sumlr(self, i, j):\n    return self.sum(j) - self.sum(i)\n  # a[i]\n  def get(self,i):\n    i+=1\n    return self.el[i]\n\nbit=BIT(n)\nfor i in range(n):\n  bit.add(i,1)\nans=0\nm=n\nfor i in range(n//2):\n  # idx=i,n-1-iにくるものを考える\n  t=-1\n  v=float('inf')\n  for j in range(26):\n    if not ary[j]:continue\n    l=ary[j][0]\n    r=ary[j][-1]\n    tmp=0\n    # lからiへ\n    tmp+=bit.sum(l)\n    # rからn-1-iへ\n    tmp+=m-2*i-bit.sum(r+1)\n    if v>tmp:\n      v=tmp\n      t=j\n  r=ary[t].pop()\n  l=ary[t].popleft()\n  bit.add(l,-1)\n  bit.add(r,-1)\n  ans+=v\nprint(ans)"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: