def result(s,n,z):
    a=z
    b=chr(ord(a)+1)
    if n==1:
        if s[0]==a:
            return 0
        else:
            return 1
    x=s[:n//2]
    y=s[n//2:]
    cx=x.count(a)
    cy=y.count(a)
    out=min((n//2-cx)+result(y,n//2,b),(n//2-cy)+result(x,n//2,b))
    return out

t=int(input())
i=0
while i<t:
    n=int(input())
    s=input()
    print(result(s,n,'a'))



    i=i+1
