alpha = "abcdefghijklmnopqrstuvwxyz"


s = ""

def solve(i, j, c):
    if i == j:
        if s[i] == alpha[c]:
            return 0
        return 1
    m = (i+j)/2
    qtdl = 0
    qtdr = 0
    k = i
    while(k <= m):
        if s[k] != alpha[c]:
            qtdl += 1
        k += 1
    while(k <= j):
        if s[k] != alpha[c]:
            qtdr += 1
        k += 1
    return min( solve(i, m, c+1) + qtdr, solve(m+1, j, c+1) + qtdl)

t = int(raw_input())
for i in range(t):
    n = int(raw_input())
    s = raw_input()
    print(solve(0, n-1, 0))
