from sys import stdin,stdout 
import math,queue,heapq
fastinput=stdin.readline
fastout=stdout.write
t=int(fastinput())
def result(s,c):
    
    n = len(s)
    if n==1 and s[0]==c:
        return 0 
    elif n==1:
        return 1 
    else:
        a = s[0:n//2]
        b = s[n//2:n]
        acount=a.count(c)
        bcount=b.count(c)
        c=chr(ord(c)+1)
        return min(len(a)-acount+result(b,c),len(b)-bcount+result(a,c))
            
    
    
    
while t:
    t-=1 
    n=int(fastinput()) 
    s=input()
    print(result(s,'a'))