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