def check(s, ch, n):
    if n == 2:
        if s[1] == ch:
            if s[0] == chr(ord(ch)+1): return 0
            else: return 1
        elif s[0] == ch:
            if s[1] == chr(ord(ch)+1): return 0
            else: return 1
        elif s[1] == chr(ord(ch)+1):
            return 1
        elif s[0] == chr(ord(ch)+1):
            return 1
        else: return 2
    count = 0
    for i in range(n//2):
        if s[i] != ch:
            count += 1
    co = 0
    for i in range(n//2, n):
        if s[i] != ch:
            co += 1
    if co == count:
        return co + min(check(s[0:n//2], chr(ord(ch)+1), n//2), check(s[n//2:n], chr(ord(ch)+1), n//2))
    elif co >  count:
        return count + check(s[n//2:n], chr(ord(ch)+1), n//2)
    else:
        
        return co + check(s[0:n//2], chr(ord(ch)+1), n//2)
for _ in range(int(input())):
    n = int(input())
    s = input()
    if n==1:
        if s  == 'a': print(0)
        else: print(1)
    else:
        print(check(s, 'a', n))