def min_moves (str, charac):
    if (len(str) == 1):
        if (str[0] == charac):
            return 0
        else:
            return 1

    else:
        n = len(str) // 2
        substr1 = str[0:n]
        step1 = 0
        substr2 = str[n:2*n]
        step2 = 0
        for i in range(len(substr1)):
            if (substr1[i] != charac):
                step1 = step1 + 1

        for i in range(len(substr2)):
            if (substr2[i] != charac):
                step2 = step2 + 1

        newchar = chr(ord(charac) + 1)

        return min(step1 + min_moves(substr2,newchar),step2 + min_moves(substr1,newchar))

list_of_ans = []

t = int(input())

for i in range(t):
    v = int(input())
    str_inp = input()
    list_of_ans.append(min_moves(str_inp,'a'))

for i in range(len(list_of_ans)):
    print(list_of_ans[i])
