import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce
sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())
def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def cnt(c,l,r,s):
	x=s[l:r+1].count(c)
	return r+1-l-x


def getmin(l,r,c,s):
	if l==r:
		if s[l]==c:
			return 0
		else:
			return 1
	mid=l+(r-l)//2
	left=cnt(c,l,mid,s)+getmin(mid+1,r,chr(ord(c)+1),s)
	right=cnt(c,mid+1,r,s)+getmin(l,mid,chr(ord(c)+1),s)
	return min(left,right)


def main():
	ans=""
	for _ in range(ii()):
		n=ii()
		s=I().strip()
		x=getmin(0,len(s)-1,"a",s)
		ans+=str(x)+"\n"
	print(ans)




		
		
	
		

	







		










		


		










		






if __name__ == '__main__':
	main()