def func(s,n,a):
    c=chr(a)
    if(n==1):
        if(s[0]==c):
            return 0
        return 1
    c1=0
    c2=0
    for i in range(n/2):
            if s[i]==c:
                c1+=1
    for i in range(n/2,n):
            if s[i]==c:
                c2+=1
    return min(n/2-c1+func(s[n/2:],n/2,a+1),n/2-c2+func(s[:n/2],n/2,a+1))
for _ in range(input()):
    n=input()
    s=raw_input()
    print func(s,n,97)
        
