
def fn(s,a):
    if len(s)==1:
        if s==a:
            return 0
        else:
            return 1

    a1=0
    a2=0
    l=len(s)//2
    t=s[:l]
    p=s[l:]
    for i in t:
            if i!=a:
                a1+=1
    for i in p:
            if i!=a:
                a2+=1
    return min(a1+fn(p,chr(ord(a)+1)),a2+fn(t,chr(ord(a)+1)))


for _ in range(int(input())):
    n=int(input())

    a=input()
    print(fn(a,'a'))
