for tt in range(int(input())):
    n=int(input())
    s=input()
    global count
    count=0
    def moves(l,r,ch):
        if (r-l)==1:
            if s[l]==ch:
                return 0
            else:
                return 1
        else:
            mid=(l+r)//2
            countl=(r-l)//2-s[l:mid].count(ch)+moves(mid,r,chr(ord(ch)+1))
            countr=(r-l)//2-s[mid:r].count(ch)+moves(l,mid,chr(ord(ch)+1))
            return min(countl,countr)
    print(moves(0,n,"a"))
            
        

    
#career bnane ke liye kuch bhi krega
