from itertools import permutations 
from sys import stdin, stdout

def minswaps(comp,name):
    diff=0
    for j in range(len(comp)):
        if(name[j]!=comp[j]):
            diff+=1
    return diff            



alpha=['a','b','c','d','e','f','g','h','i','j','k','l','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

test=int(stdin.readline())

for j in range(test):
    n=int(stdin.readline())
    name = stdin.readline()
    k=n//2
    e=0
    ls=[]
    while(k>0):
        st=""
        for i in range(k):
            try:
                st+=alpha[e]
            except:
                print(e)    
        ls.append(st)
        k=k//2
        e+=1
    st=""
    st+=alpha[e-1]+alpha[e]
    ls.insert(-1,st)
    ls.pop() 
    comp=[] 
    if(len(ls)==0):
       ls.append('a')  
    l = list(permutations(ls))  
    for i in range(len(l)):
        st=""
        if(l[i][-1]==ls[0] or l[i][0]==ls[0]):
            for p in range(len(l[i])):
                st+=l[i][p]
            comp.append(st)
    ans=100000000
    for p in range(len(comp)):
        ans=min(ans,minswaps(comp[p],name))
    st=""
    st+=alpha[e]+alpha[e-1]
    ls.insert(-1,st)
    ls.pop()
    comp=[] 
    if(len(ls)==0):
       ls.append('a')  
    l = list(permutations(ls))  
    for i in range(len(l)):
        st=""
        if(l[i][-1]==ls[0] or l[i][0]==ls[0]):
            for p in range(len(l[i])):
                st+=l[i][p]
            comp.append(st)
    for p in range(len(comp)):
        ans=min(ans,minswaps(comp[p],name))
    print(ans)               