from os import path
import sys,time, collections as c , math as m , pprint as p
maxx , localsys , mod = float('inf'), 0 , int(1e9 + 7) 
if (path.exists('input.txt')):  sys.stdin=open('input.txt','r') ;   sys.stdout=open('output.txt','w')
input = sys.stdin.readline
def f(s, c, start , end):
    N, ans  = len(s) , 0
    if N  == 0:
        return maxx
    for i in range(start , end):
        if s[i] != c:
            ans+=1
    return ans

def recur(s , c):
    x , y  = f(s, c ,0 , len(s)//2) , f(s, c , len(s)//2 , len(s))
    if len(s) == 1:
        x ,y = max(x, y ), max(x, y)
    if x <= y:
        a.append(x)
        # print(x , y , s , c , a )
        if len(s)//2 == 0:
            return a
        return recur(s[len(s)//2:], chr(ord(c)+1))
    else:
        a.append(y)
        # print(x , y , s , c ,a)
        if len(s) // 2 == 0:
            return a
        return recur(s[:len(s)//2] , chr(ord(c)+1))

for _ in range(int(input())):
    n = int(input()) ; s = input().rstrip('\n')
    global a
    a = []
    p = recur(s, 'a')
    print(sum(p))


