import math

t = int(input())
an = []
for i in range(t):
    n = int(input())
    k = int(math.log(n, 2))
    s = input()
    ans = 0
    ind = 97
    while len(s) != 0:
        half = s[0:len(s) // 2]
        half1 = s[len(s) // 2:len(s)]
        if chr(ind) in half:
            for r in half:
                if r != chr(ind):
                    ans += 1
            s = half1
        else:
            for r in half1:
                if r != chr(ind):
                    ans += 1
            s = half
        ind += 1
    an.append(ans)
for i in an:
    print(i)
