def fun1(s,n,k):
    cnt = s.count(k)
    return n-cnt
 
def fun(s,n,k):
    if n==1:
        if s==k:
            return 0
        else:
            return 1
    else:
        n=n//2
        o = ord(k)-97
        k1 = chr(o+98)
        return min(fun1(s[:n],n,k)+fun(s[n:],n,k1),fun(s[:n],n,k1)+fun1(s[n:],n,k))
 
for _ in range (int(input())):
    n = int(input())
    s=input()
    print(fun(s,n,'a'))