cache = {}
def foo(c, s):
    if len(s) == 1:
        if s == c:
            return 0
        return 1

    if (c, s) in cache:
        return cache[(c, s)]

    n = len(s)
    mid = n >> 1
    first = s[:mid]
    second = s[mid:]
    val1 = mid - first.count(c) + foo(chr(ord(c) + 1), second)
    val2 = mid - second.count(c) + foo(chr(ord(c) + 1), first)
    val = min(val1, val2)
    cache[(c, s)] = val
    return val

t = int(input())
for _ in range(t):
    n = int(input())
    s = input().strip()
    print(foo('a', s))
