from sys import stdin
input=lambda : stdin.readline().strip()

def check(s,ch):
    s1 = s[0:len(s)//2] # first half
    s2 = s[len(s)//2:] # second half
    ans = 0
    x = chr(ch)
    if(s1.count(x)>=s2.count(x)):
        ans = 1 
    elif(s2.count(x)>s1.count(x)):
        ans = 2 
    return ans

def good(s,ch):
    count = 0
    count = len(s) - s.count(chr(ch))
    return count

for _ in range(int(input())):
    n = int(input())
    s = list(input())
    c = 0
    if('a' in s):
        a = 97
    else:
        a = 98
    if(len(s)==1 and s[0]=='a'):
        print(0)
    elif(len(s)==1 and s[0]!='a'):
        print(1)
    elif(len(s)>1):
        while(True):
            if(len(s)>1):
                if(chr(a) not in s and len(s)==2):
                    a+=1
                mid = len(s)//2
                if(check(s,a) == 1):
                    c += good(s[0:mid],a)
                    s = s[mid:] # take 2nd half for further operations
                    a += 1 
                elif(check(s,a) == 2):
                    c += good(s[mid:],a)
                    s = s[0:mid] # take 1st half for further operations
                    a += 1
                    
            elif(len(s)==1):
                c += good(s,a)
                break
        print(c)
        
        
