def cgs(x, y, c, s):
    if y - x <= 1:
        if s[x] != c:
            return 1
        else:
            return 0
    n = y - x
    a, b, m = 0, 0, x+(y-x)//2
    for j in range(x, m):
        if s[j] == c:
            a += 1
    for j in range(m, y):
        if s[j] == c:
            b += 1
    ch = chr(ord(c)+1)
    return min(n//2 - a + cgs(m, y, ch, s), n//2 - b + cgs(x, m, ch, s))

for i in range(int(input())):
    n = int(input())
    s = input()
    print(cgs(0, n, 'a', s))
