def solve(string, character):
    long = len(string)
    if long == 1:
        if chr(character) == string:
            return 0
        return 1
    if long == 2:
        q1, q2 = chr(character), chr(character+1)
        a, b = string[0], string[1]
        if (q1 == a and q2 == b) or (q1 == b and q2 == a):
            return 0
        if q1 == a or q1 == b or q2 == a or q2 == b:
            return 1
        return 2
    dp1 = long // 2 - string[:(long//2)].count(chr(character)) + solve(string[(long//2):], character+1)
    dp2 = long // 2 - string[(long//2):].count(chr(character)) + solve(string[:(long//2)], character+1)
    return min(dp1, dp2)


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