g = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
     "x", "y", "z"]


def solve(s, ch):
    # print(s,ch)
    if len(s) == 1:
        if s[0] == ch:
            return 0
        else:
            return 1
    countf = 0
    counts = 0
    for i in range((len(s) // 2)):
        if s[i] == ch:
            countf += 1
    for i in range((len(s) // 2), len(s)):
        if s[i] == ch:
            counts += 1
    # print(countf,counts)
    if countf==counts:
        return min((len(s) // 2 - countf) + solve(s[len(s) // 2:], g[g.index(ch) + 1]),(len(s) // 2 - counts) + solve(s[:(len(s) // 2)], g[g.index(ch) + 1]))
    elif countf > counts:
        return (len(s) // 2 - countf) + solve(s[len(s) // 2:], g[g.index(ch) + 1])
    else:
        return (len(s) // 2 - counts) + solve(s[:(len(s) // 2)], g[g.index(ch) + 1])


for _ in range(int(input())):
    n = int(input())
    s = input()
    print(solve(s, "a"))
