for _ in range(0,int(input())):
        n = int(input())
        s = input()
        def call(l,r,ch):
                if(l==r): return (s[l]!=ch)+0
                c=0
                for i in range(l,(l+r+1)//2):
                        if(s[i]!=ch): c+=1
                left = c+call((l+r+1)//2,r,chr(ord(ch)+1))
                c=0
                for i in range(r,(l+r)//2,-1):
                        if(s[i]!=ch): c+=1
                right = c+call(l,(l+r)//2,chr(ord(ch)+1))
                return min(left,right)

        print(call(0,n-1,'a'))
