
#import collections  
#from collections import defaultdict  
def fun(s,r):
    if len(s)==1:
        if s[0]==r:
        	return 0 
        else:
        	return 1

    z=chr(ord(r)+1)
    x=len(s)//2
    r11=s[:x].count(r)
    r12=s[x:].count(r)
    r21=s[:x].count(z)
    r22=s[x:].count(z)
    

    if r11>r12:
      return (x-r11)+fun(s[x:],z)

    elif r11<r12:
        return (x-r12)+fun(s[:x],z)

    else:
        if r21<r22:
        	return (x-r11)+fun(s[x:],z) 

        else:
        	return (x-r11)+fun(s[:x],z) 


for _ in range(int(input())):

    n=int(input())
    #a=[int(x) for x in input().split()]
    s=input()  
    print( fun(s,'a'))











