def rec(s, cc, oc):
    global ans
    ls = len(s)
    if ls == 1:
        if s[0] != cc:
            ans += 1
        return
    ss = s[ls // 2:]
    fs = s[:ls // 2]
    sans = ans
    for i in range(ls // 2):
        if s[i] != cc:
            s[i] = cc
            ans += 1
    rec(ss, chr(oc + 1), oc + 1)
    ans1 = ans
    ans = sans
    for i in range(ls // 2, ls):
        if s[i] != cc:
            s[i] = cc
            ans += 1
    rec(fs, chr(oc + 1), oc + 1)
    ans = min(ans1, ans)
for _ in range(int(input())):
    input()
    ss = list(input())
    ans = 0
    rec(ss, 'a', 97)
    print(ans)

