def f(s,c):
    n=len(s)
    if n==1:
        if s[0]==c:
            return 0
        else:
            return 1
    a=(s[:n//2]).count(c)
    b=(s[n//2:]).count(c)
    return min(n//2-a+f(s[n//2:],c+1), n//2-b+f(s[:n//2],c+1))


def f2(s):
    arr=[]
    for i in s:
        arr.append(ord(i)-96)
    return arr 
    
    
for t in range(int(input())):   
    n=int(input())
    s=str(input())
    arr=f2(s)
    print(f(arr,1))