d = {}
def equal(s, a):
    c = s.count(a) if a in s else 0
    return len(s) - c
def solve(s, a):
    if d.get((s, a), -1) != -1:
        return d[(s, a)]
    n = len(s)
    if n == 1:
        if s == a:
            return 0
        else:
            return 1
    x = solve(s[:n // 2], chr(ord(a) + 1)) + equal(s[n // 2:], a)
    y = solve(s[n // 2:], chr(ord(a) + 1)) + equal(s[:n // 2], a)
    t = min(x, y)
    d[(s, a)] = t
    return t

for _ in range(int(input())):
    n = int(input())
    s = input()
    if n == 1:
        if s == "a":
            print(0)
        else:
            print(1)
        continue
    a = "a"
    print(min(equal(s[:n // 2], a) + solve(s[n // 2:], chr(ord(a) + 1)), equal(s[n // 2:], a) + solve(s[:n // 2], chr(ord(a) + 1))))