Emily and Mia are friends. Emily got Mia’s essay paper, but since she is a prankster, she decided to meddle with the words present in the paper. She changes all the words in the paper into palindromes. To do this, she follows two rules: 
- In one operation she can only reduce the value of an alphabet by 1, i.e.  she can change ‘d’ to ‘c’, but she cannot change ‘c’ to ‘d’ or ‘d’ to ‘b’. 
- The alphabet ‘a’ will not be reduced any further. 
Each reduction in the value of any alphabet is counted as a single operation. Find the minimum number of operations required to convert a given string into a palindrome.

-----Input:-----
- The first line contains an integer $T$, denoting the number of test cases. 
- Each test case consists of a string $S$ containing only lowercase characters with no spaces.

-----Output:-----
For each test case on a new line, print the minimum number of operations for the corresponding test case.

-----Constraints-----
- $1<=T<=10$
- $1<=|S|<=10^7$, where $|S|$ denotes length of string S.

-----Sample Input:-----
4 
abc 
abcba 
abcd 
cba

-----Sample Output:-----
2 
0
4
2

-----EXPLANATION:-----
For the first test case string = “abc” 
c->b->a so the string become “aba” which is a palindrome. For this we perform 2 operations

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
t = int(input())
for _ in range(t):
	xyz = input().strip()
	string = 0
	for i in range(len(xyz) // 2):
		string = string + abs(ord(xyz[i]) - ord(xyz[len(xyz) - i - 1]))
	print(string)


numbers = int(input())
for x in range(numbers):
	st = input().strip()
	l = len(st)
	res = 0
	j = l - 1
	i = 0
	while i < j:
		if st[i] != st[j]:
			res += abs(ord(st[i]) - ord(st[j]))
		i = i + 1
		j = j - 1
	if res == 0:
		print(0)
	else:
		print(res)


t = int(input())
for _ in range(t):
	l = input().strip()
	s = 0
	for i in range(len(l) // 2):
		s = s + abs(ord(l[i]) - ord(l[len(l) - i - 1]))
	print(s)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def seive():
	prime = [1 for i in range(10 ** 6 + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(10 ** 6 + 1):
		if prime[i]:
			for j in range(2 * i, 10 ** 6 + 1, i):
				prime[j] = 0
	return prime
for _ in range(L()[0]):
	s = input().strip()
	n = len(s)
	ans = 0
	for i in range((n - n % 2) // 2):
		ans += abs(ord(s[i]) - ord(s[n - 1 - i]))
	print(ans)
endtime = time.time()


t = int(input())
lst = ['0', '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']
for i in range(t):
	s = list(input().strip())
	count = 0
	s.insert(0, 'temp')
	for i in range(1, len(s)):
		if i > len(s) // 2:
			break
		if s[i] != s[-i]:
			count += abs(lst.index(s[i]) - lst.index(s[-i]))
	print(count)


t = int(input())
for _ in range(t):
	a = input().strip()
	a = list(a)
	b = 'abcdefghijklmnopqrstuvwxyz'
	if a == a[::-1]:
		print(0)
	else:
		c = 0
		j = len(a) - 1
		for i in range(0, len(a) // 2):
			if a[i] != a[j]:
				k = max(a[i], a[j])
				p = min(a[i], a[j])
				c += ord(k) - ord(p)
			j -= 1
		print(c)


n = int(input())
for i in range(n):
	s = input().strip()
	c = 0
	I = 0
	J = len(s) - 1
	while I < J:
		c += abs(ord(s[I]) - ord(s[J]))
		I += 1
		J -= 1
	print(c)


for _ in range(int(input())):
	S = input().strip()
	(i, j) = (0, len(S) - 1)
	count = 0
	while i < j:
		if S[i] != S[j]:
			count += abs(ord(S[i]) - ord(S[j]))
		i += 1
		j -= 1
	print(count)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return list(map(int, inp().split()))

def smp():
	return list(map(str, inp().split()))

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	s = inp()
	l = len(s)
	i = 0
	j = l - 1
	c = 0
	while j > i:
		c += abs(ord(s[i]) - ord(s[j]))
		i += 1
		j -= 1
	print(c)


t = int(input())
for _ in range(t):
	str1 = input().strip()
	n = len(str1)
	res = 0
	for i in range(0, int(n / 2)):
		res += abs(ord(str1[i]) - ord(str1[n - i - 1]))
	print(res)


for t in range(int(input())):
	a = input().strip()
	c = 0
	n = len(a)
	for i in range(n // 2):
		c += abs(ord(a[i]) - ord(a[n - i - 1]))
	print(c)


from sys import stdin, stdout, stderr, setrecursionlimit
from math import pi, sqrt, gcd, ceil, floor, log2, log10, factorial
from math import cos, acos, tan, atan, atan2, sin, asin, radians, degrees, hypot
from bisect import insort, insort_left, insort_right, bisect_left, bisect_right, bisect
from functools import reduce
from itertools import combinations, combinations_with_replacement, permutations
from fractions import Fraction
from random import choice, getrandbits, randint, random, randrange, shuffle
from re import compile, findall, escape, search, match
from statistics import mean, median, mode
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, merge, nlargest, nsmallest
from collections import deque, OrderedDict, defaultdict
from collections import Counter, namedtuple, ChainMap, UserDict, UserList, UserString
from numpy import dot, trace, argmax, argmin, array, cumprod, cumsum, matmul
mod = 10 ** 9 + 7
hell = 10 ** 9 + 9
inf = 10 ** 18
lcm = lambda x, y: x * y // gcd(x, y)
add = lambda x, y: (x % mod + y % mod) % mod
sub = lambda x, y: (x % mod - y % mod + mod) % mod
mul = lambda x, y: x % mod * (y % mod) % mod
inverse = lambda x: pow(x, mod - 2, mod)
setBitCount = lambda x: bin(x).count('1')
sumOfDigits = lambda x: sum([int(i) for i in str(x)])
size = 10 ** 6 + 1
setrecursionlimit(size)

def preCompute():
	return

def solve():
	return

def main():
	io = IO()
	testcases = 0
	if testcases == 0:
		testcases = io.nextInt()
	preCompute()
	for test in range(testcases):
		s = io.String()
		n = len(s)
		ans = 0
		for i in range(n // 2):
			ans += abs(ord(s[i]) - ord(s[n - i - 1]))
		io.write(ans)

class IO:

	def next(self):
		return stdin.readline().strip()

	def nextLine(self):
		return self.next()

	def String(self):
		return self.next()

	def nextStrings(self):
		return list(map(str, self.next().split()))

	def nextInt(self):
		return int(self.next())

	def Int(self):
		return self.nextInt()

	def nextFloat(self):
		return float(next())

	def Float(self):
		return self.nextFloat()

	def nextList(self):
		return list(map(int, self.next().split()))

	def List(self):
		return self.nextList()

	def nextTuple(self):
		return tuple(map(int, self.next().split()))

	def Tuple(self):
		return self.nextTuple()

	def debug(self, *obj, sep=' ', end='\n'):
		string = sep.join([str(item) for item in obj]) + end
		stderr.write(string)

	def print(self, *obj, sep=' ', end='\n'):
		string = sep.join([str(item) for item in obj]) + end
		stdout.write(string)

	def write(self, *obj, sep=' ', end='\n'):
		self.print(*obj, sep=sep, end=end)
main()


for test in range(int(input())):
	s = input().strip()
	if not len(s) % 2:
		mid = len(s) // 2
		first = s[:mid]
		second = s[mid:]
	else:
		mid = len(s) // 2
		first = s[:mid]
		second = s[mid + 1:]
	second = second[::-1]
	cost = 0
	for i in range(len(first)):
		cost += abs(ord(first[i]) - ord(second[i]))
	print(cost)