def count(s, c):
    n = 0
    for i in s:
        if i!=c: n += 1
    return n

def get_count(s, c):
    if len(s) == 1:
        return count(s, c)
    m = len(s)//2
    c1 = count(s[:m], c) + get_count(s[m:], chr(ord(c)+1))
    c2 = count(s[m:], c) + get_count(s[:m], chr(ord(c)+1)) 
    return(min(c1 ,c2))

inp = lambda: input()
t = int(inp())
for _ in range(t):
    n = int(inp())
    s = inp()
    # print(s, len(s))
    print(get_count(s, "a"))
