import sys
tcs = int(input())
def f(s, c):
    if len(s) == 1:
        if s[0] == c:
            return 0
        else:
            return 1
    mid = len(s) // 2
    cntl = f(s[:mid], chr(ord(c)+1))
    cntl += len(s)//2 - s[mid:].count(c)
    cntr = f(s[mid:], chr(ord(c)+1))
    cntr += len(s)//2 - s[:mid].count(c)
    return min(cntl, cntr)

for tc in range(tcs):
    n = int(input())
    s = list(input())
    print(f(s, 'a'))

