l='abcdefghijklmnopqrstuvwxyz'
def g(s,i):
    return len(s)-s.count(l[i])
def f(s,i):
    k=int(math.log2(len(s)))
    if k==0:
        if s==l[i]:
            return 0
        else:
            return 1
    s1=s[:2**(k-1)]
    s2=s[(2**(k-1)):]
    return min(g(s1,i)+f(s2,i+1),f(s1,i+1)+g(s2,i))
import math
for _ in range(int(input())):
    n=int(input())
    k=int(math.log2(n))
    s=input()
    ans=0
    p=n//2
    if k==0:
        if s=='a':
            print(0)
        else:
            print(1)
    else:
        print(f(s,0))
   