def check(s, ch, n):
    if n == 1:
        if s==ch: 
            return 0
        else: return 1
    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:
    #0    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 min(count + check(s[n//2:n], chr(ord(ch)+1), n//2), 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))