import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
import string
lower=string.ascii_lowercase
def same(s,i):
    if(len(s)==1):
        if(s[0]==lower[i]):
            return 0
        else:
            return 1
    else:
        ans=0
        for j in s:
            if(j!=lower[i]):
                ans+=1
        return ans
def find(s,i):
    if(len(s)==1):
        if(s[0]==lower[i]):
            return 0
        else:
            return 1
    else:
        return(min(same(s[:len(s)//2],i)+find(s[len(s)//2:],i+1),same(s[len(s)//2:],i)+find(s[:len(s)//2],i+1)))
t=int(input())
for _ in range(t):
    n=int(input())
    s=input()
    print(find(s,0))