import math
import collections
from sys import stdin,stdout,setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2**20)
 
t = 1
t = int(stdin.readline())

def str_cal(s,d,n,c):
    if(n==1):
        if(d[c]==s[0]):
            return 0
        else:
            return 1
    
    cnt1 = 0
    for i in s[:n//2]:
        if(i!=d[c]):
            cnt1+=1
    
    cnt2 = 0
    for i in s[n//2:]:
        if(i!=d[c]):
            cnt2+=1
    
    return min( cnt2+str_cal(s[:n//2],d,n//2,c+1), cnt1+str_cal(s[n//2:],d,n//2,c+1) )
    


for _ in range(t):
    n = int(stdin.readline())
    s = str(stdin.readline().strip('\n'))
    #a = list(map(int, stdin.readline().rstrip().split()))
    d = {}
    cnt = 1
    for i in ('abcdefghijklmnopqrstuvwxyz'):
        d[cnt] = i
        cnt += 1
    
    print(str_cal(s,d,n,1))