def sol(s,n,c):
    if n==1:
        if s[0]==c:
            return 0
        else:
            return 1
    s1=s[0:n//2]
    s2=s[n//2:]
    if c in s1:
        x=s1.count(c)
        #print(s2,n//2,chr(ord(c) + 1),n//2-x)
        return (n//2-x)+sol(s2,n//2,chr(ord(c) + 1))
    else:
        if c in s2:
            x=s2.count(c)
            #print(s1,n//2,chr(ord(c) + 1),n//2-x)
            return (n//2-x)+sol(s1,n//2,chr(ord(c) + 1))
        elif chr(ord(c)+1) in s2:
            x=s1.count(c)
            #print(s2,n//2,chr(ord(c) + 1),n//2-x)
            return (n//2-x)+sol(s2,n//2,chr(ord(c) + 1))
        else:
            x=s2.count(c)
            #print(s1,n//2,chr(ord(c) + 1),n//2-x)
            return (n//2-x)+sol(s1,n//2,chr(ord(c) + 1))
            
t=int(input())
while t>0:
    n=int(input())
    l=[i for i in input()]
    print(sol(l,n,"a"))
    t-=1