
# from collections import Counter
# import math
alpha = 'abcdefghijklmnopqrstuvqxyz'


def solve(s, lvl, cost):
    n = len(s)

    if n == 1:
        if s == alpha[lvl]:
            return cost
        else:
            return cost + 1
    # cost to change first half
    c1 = n // 2 - s[:n // 2].count(alpha[lvl]) + solve(s[n // 2:], lvl + 1, cost)
    # cost to change second half
    c2 = n // 2 - s[n // 2:].count(alpha[lvl]) + solve(s[:n // 2], lvl + 1, cost)
    return cost + min(c1, c2)


def tc():
    n = int(input())
    s = input()

    ans = solve(s, 0, 0)
    print(ans)


##################################
T = int(input())

for _ in range(T):
    tc()

# tc()
