from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)


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



    @lru_cache(maxsize=None)
    def co(l, r, ch):
        return ((r - l) - s[l:r].count(ch))


    @lru_cache(maxsize=None)
    def f(i, l, r):
        ch = chr(97 + i)
        if (r - l == 1):
            if (ch == s[l]):
                return 0
            else:
                return 1
        mid = l + (r - l) // 2
        return min(co(l, mid, ch) + f(i + 1, mid, r), co(mid, r, ch) + f(i + 1, l, mid))
    print(f(0, 0, n))