import math
def cost(s,key):
    res=0
    for i in s:
        if (ord(i)-96)!=key:
            res+=1
    return res
for _ in range(int(input())):
    n=int(input())
    s=input('')
    def check(s,key):
        if len(s)==1:
            return cost(s,key)
        return min(check(s[:len(s)//2],key+1)+cost(s[len(s)//2:],key),check(s[len(s)//2:],key+1)+cost(s[:len(s)//2],key))
    print(check(s,1))
