import sys
input = sys.stdin.readline

def mins(S,c):
    #print(S,c)
    if len(S)==1:
        if S==c:
            return 0
        else:
            return 1

    LEN=len(S)//2

    X=S[:LEN]
    Y=S[LEN:]

    ANS1=0
    ANS2=0
    for x in X:
        if x!=c:
            ANS1+=1

    for y in Y:
        if y!=c:
            ANS2+=1

    return min(ANS1+mins(Y,chr(ord(c)+1)),ANS2+mins(X,chr(ord(c)+1)))
        

t=int(input())
for tests in range(t):
    n=int(input())
    S=input().strip()

    print(mins(S,"a"))

    
        
