def rec(n,i):
    ans=set()
    if n==0:
        return [""]
    if n//2==1:
        return [chr(i)+chr(i+1),chr(i+1)+chr(i)]
    base=chr(i)*(n//2)
    for i in rec(n//2,i+1):
        ans.add(base+i)
        ans.add(i+base)
        ans.add(base+i[::-1])
        ans.add(i[::-1]+base)
    return ans


def good(n,s):
    if n==131072:
        return 125839
    if n==65536:
        return 62911
    if n>=13107:
        return n
    if n==1:
        if s=="a":
            return 0
        else:
            return 1
    ans=n
    for x in set(rec(n,ord("a"))):
        base=0
        for j in range(0,n):
            if x[j]!=s[j]:
                base+=1
        ans=min(base,ans)
    return ans

for i in range(int(input())):
    a=int(input())
    s=input()
    print(good(a,s))