from sys import stdin
input = lambda: stdin.readline().rstrip("\r\n")
from collections import deque as que, defaultdict as vector
from heapq import*
inin = lambda: int(input())
inar = lambda: list(map(int,input().split()))
from types import GeneratorType
from math import log2
alp='abcdefghijklmnopqrstuvwxyz'
def bootstrap(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to

    return wrappedfunc
@bootstrap
def solve(c,l,r,s):
	#print(c,l,r,s)
	mid=(l+r)//2
	c1=0
	c2=0
	ch=alp[c]
	if l==r-1:
		if ch==s[l]:
			yield 0
		else:
			yield 1
	for i in range(l,mid):
		if s[i]!=ch:
			c1+=1
	for i in range(mid,r):
		if s[i]!=ch:
			c2+=1
	yield min(c1+(yield solve(c+1,mid,r,s)),c2+(yield solve(c+1,l,mid,s)))

	

Testcase=inin()
for i in range(Testcase):
	n=inin()
	s=input()
	k=int(log2(n)+1)
	print(solve(0,0,n,s))