for _ in range(int(input())):
    n=int(input())
    s=input()
    i=ord('a')
    count=0
    while(True):
        #print(s)
        if n==1:
            if s[0]!=chr(i):
                count+=1
            break
        a=s[:n//2].count(chr(i))
        c1=s[:n//2].count(chr(i+1))
        b=s[n//2:].count(chr(i))
        c2=s[n//2:].count(chr(i+1))
        if a>b:
            s=s[n//2:]
            count+=(n//2-a)
            n=n//2
            
        elif a<b:
            s=s[:n//2]
            count+=(n//2-b)
            n=n//2
        else:
            if c1>c2:
                s=s[:n//2]
                count+=(n//2-b)
                n=n//2
            else:
                s=s[n//2:]
                count+=(n//2-a)
                n=n//2
                
        i+=1
    print(count)
                