t=int(input())
def recurse(st,c,moves):
    if len(st)==1:
        if st==c:
            return moves
        else:
            return moves+1
    m=moves
    n=0
    n1=0
    for a in range(len(st)):
        if st[a]==c and a<len(st)//2:
            n+=1
        elif st[a]==c:
            n1+=1
    if n>n1:
        return recurse(st[len(st)//2:],chr(ord(c)+1),m+len(st)//2-n)
    elif n<n1:
        return recurse(st[:len(st)//2:],chr(ord(c)+1),m+len(st)//2-n1)
    else:
        return min(recurse(st[len(st)//2:],chr(ord(c)+1),m+len(st)//2-n),recurse(st[:len(st)//2:],chr(ord(c)+1),m+len(st)//2-n1))
for t1 in range(t):
    x=int(input())
    st=input()
    m=recurse(st,'a',0)
    print(m)
    
        
