def calculer(s,char,n,num):
    a=0
    x=[0]*4
    y=[0]*4
    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 n==0:
        return [s,char,0,num]
    else:
        if c2>c1:
            return calculer(ch1,chr(ord(char)+1),n//2,num+a-c2)
        elif c1>c2 :
            return calculer(ch2,chr(ord(char)+1),n//2,num+a-c1)
        
        else:
            x=calculer(ch1,chr(ord(char)+1),n//2,num+a-c2)
            y=calculer(ch2,chr(ord(char)+1),n//2,num+a-c1)
            if x[3]>y[3]:
                return y
            else:
                return x
def main():
    t=int(input())
    for _ in range(t):
        n=int(input())
        s=input()
        l=calculer(s,'a',n,0)
        print(l[3])

if __name__=="__main__":
    main()
