##import sys
##sys.stdin = open("input.txt")

def sinistra(s,c):
    if len(s) == 1:
        if s == alph[c]:
            return 0
        else:
            return 1
    conta = 0
    for n in range(len(s)//2):
        if s[n] != alph[c]:
            conta +=1
    s = s[len(s)//2:]
    return conta + check(s,c+1)
def destra(s,c):
    if len(s) == 1:
        if s == alph[c]:
            return 0
        else:
            return 1
    conta = 0
    for n in range(len(s)//2):
        if s[n+len(s)//2] != alph[c]:
            conta +=1
    s = s[:len(s)//2]
    return conta + check(s,c+1)

def check(s,c):
    return min(sinistra(s,c),destra(s,c))


a=ord('a')
alph=[chr(i) for i in range(a,a+26)]
T = int(input())
for t in range(T):
    N = int(input())
    s = input()
    print (check(s,0))
    
