import copy
def next(ch):
    return chr(ord(ch)+1)
def solve(f,a,low,high):
    ans=0
    ch='a'
    while(low<high):
        mid = low + (high-low)//2
        if low==mid:
            if a[low]!=ch:
                ans+=1
            break
        if f:
            f=0
            i=low
            while(i<mid):
                if a[i]!=ch:
                    ans+=1
                i+=1
            low=mid
            ch=next(ch)
        else:
            f=1
            i=high-1
            while(i>=mid):
                if a[i]!=ch:
                    ans+=1
                i-=1
            high=mid
            ch=next(ch)
    return ans
for _ in range(int(input())):
    n=int(input())
    s=list(input())
    ans1=solve(1,s,0,n)
    ans2=solve(0,s,0,n)
    print(min(ans1,ans2))
    