
for _ in range(int(input())):
    n = int(input())
    s = input()
    if n==1:
        if s[0]=='a':
            print(0)
        else:
            print(1)
    else: 
        min1,min2 = 0,0
        for j in range(2):
            x = 97
            left,right = 0,n
            if j==0:
                while 1:
                    if (right-left)==1:
                        if s[left]!=chr(x):
                            min1+=1
                        break
                    count1 = 0
                    for i in range(left,left+(right-left)//2):
                        if s[i]==chr(x):
                            count1+=1
                    count2 = 0
                    for i in range(left+(right-left)//2,right):
                        if s[i]==chr(x):
                            count2+=1
                    if count1>=count2:
                        min1+=((right-left)//2-count1)
                        left = left+(right-left)//2
                    elif count1<count2:
                        min1+=((right-left)//2-count2)
                        right = left+(right-left)//2
                    x+=1
            else:
                while 1:
                    if (right-left)==1:
                        if s[left]!=chr(x):
                            min2+=1
                        break
                    count1 = 0
                    for i in range(left,left+(right-left)//2):
                        if s[i]==chr(x):
                            count1+=1
                    count2 = 0
                    for i in range(left+(right-left)//2,right):
                        if s[i]==chr(x):
                            count2+=1
                    if count1>count2:
                        min2+=((right-left)//2-count1)
                        left = left+(right-left)//2
                    elif count1<=count2:
                        min2+=((right-left)//2-count2)
                        right = left+(right-left)//2
                
                    x+=1
                print(min(min1,min2))