t = int(input())


b = 'abcdefghijklmnopqrstuvwxyz'



def solve(step,s,res):

    N = len(s)
    
    hs1 = s[0:N//2]
    hs2 = s[N//2:N]


    d1 = len(hs1)-hs1.count(b[step])        

    d2 = len(hs2)-hs2.count(b[step])        


    if N>1:
        res1=solve(step+1,hs2,res+d1)
        res2=solve(step+1,hs1,res+d2)
        res = min(res1,res2)
    else: 
        
        if s!=b[step]:
            res += 1

    return res
m = {}

for _ in range(0,t):

    n = int(input())
    s = input()

    print(solve(0,s,0))
