from sys import stdin,stdout
import math 
from collections import Counter,deque
L=lambda:list(map(int, stdin.readline().strip().split()))
M=lambda:map(int, stdin.readline().strip().split())
I=lambda:int(stdin.readline().strip())
IN=lambda:stdin.readline().strip()
C=lambda:stdin.readline().strip().split()
mod=1000000007
#Keymax = max(Tv, key=Tv.get)
def s(a):print(" ".join(list(map(str,a))))
#______________________-------------------------------_____________________#
#I_am_pavan
def good(s,c):
    n=len(s)
    if n==1:
        if s[0]==c:
            return 0
        else:
            return 1
    l=n//2-s[:n//2].count(c)+good(s[n//2:],chr(ord(c)+1))
    r=n//2-s[n//2:].count(c)+good(s[:n//2],chr(ord(c)+1))
    return min(l,r)
def solve():
    n=I()
    s=IN()
    print(good(s,'a'))
for _ in range(I()):
    solve()
