
#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)


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


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

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











