import sys
sys.setrecursionlimit(200000)


def mapper(c):
    return ord(c) - ord('a')


def remapper(c):
    return (chr(c + ord('a')))


for _ in range(int(input())):
    n = int(input())
    s = input()

    def func(st, end, ch):
        if st == end:
            if s[st] == ch:
                return 0
            else:
                return 1
        m = (st + end) // 2
        c1 = func(m + 1, end, remapper(mapper(ch) + 1))
        c2 = func(st, m, remapper(mapper(ch) + 1))
        for i in range(st, m + 1):
            if s[i] != ch:
                c1 += 1
        for i in range(m + 1, end + 1):
            if s[i] != ch:
                c2 += 1
        return min(c1, c2)

    print(func(0, n-1, 'a'))
