#####################################   
import atexit, io, sys, collections, math, heapq,fractions
buffer = io.BytesIO() 
sys.stdout = buffer
@atexit.register 
def write(): sys.__stdout__.write(buffer.getvalue())   

##################################### 



def f(s,c):
	if len(s) == 1:
		return 1 if s[0] != c else 0
	pre = s[:len(s)/2]
	suf = s[len(s)/2:]
	cc = 0
	for e in pre:
		cc += 1 if e != c else 0 
	dd = 0
	for e in suf:
		dd += 1 if e != c else 0 
	aa = cc + f(suf, c+1)
	bb = f(pre, c+1) + dd
	return min(aa,bb)

for _ in range(int(raw_input())):
	n = int(raw_input())
	s = map(lambda x:ord(x)- ord('a'),list(raw_input()))
	print f(s,0)
