t=int(input())
for _ in range(t):
    n=int(input())
    s=input()
    num=0
    char='a'
    while n>0:
        if n==1:
            a=1
        else:
            a=n//2
        ch1=s[0:a]
        ch2=s[a:n]
        c1=ch1.count(char)
        c2=ch2.count(char)
        if c2>c1:
            num+=(a-c2)
            char=chr(ord(char)+1)
            s=ch1
        else:
            num+=(a-c1)
            char=chr(ord(char)+1)
            s=ch2
        n=n//2
        #print(num)
    print(num)
