import math
def calcula(left,rigth,c,s):
    if(rigth==left):
        if(s[left]==c):
            return 0
        else:
            return 1
    meio=(left+rigth)//2
    a1=((rigth-left+1)//2)-s[left:meio+1].count(c)+calcula(meio+1,rigth,chr(ord(c)+1),s)
    a2=((rigth-left+1)//2)-s[meio+1:rigth+1].count(c)+calcula(left,meio,chr(ord(c)+1),s)
    return min(a1,a2)
t=int(input())
for w in range(t):
    n=int(input())
    s=input()
    if(n==1):
        if(s=='a'):
            print(0)
        else:
            print(1)
    else:
        print(calcula(0,n-1,'a',s))