def calculer(s,char,n):
    a=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 n==0:
        return 0
    else:
        return min(a-c1+calculer(ch2,chr(ord(char)+1),n//2),a-c2+calculer(ch1,chr(ord(char)+1),n//2))
        """
        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)
            print(x,y)
            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)
        print(l)

if __name__=="__main__":
    main()
