from collections import Counter
import string
import math
import sys
from fractions import Fraction
def array_int():
    return [int(i) for i in sys.stdin.readline().split()]
def vary(arrber_of_variables):
    if arrber_of_variables==1:
        return int(sys.stdin.readline())
    if arrber_of_variables>=2:
        return map(int,sys.stdin.readline().split()) 
def makedict(var):
    return dict(Counter(var))
# i am noob wanted to be better and trying hard for that
def printDivisors(n): 
    divisors=[]  
    # Note that this loop runs till square root 
    i = 1
    while i <= math.sqrt(n): 
          
        if (n % i == 0) : 
              
            # If divisors are equal, print only one 
            if (n//i == i) : 
                divisors.append(i) 
            else : 
                # Otherwise print both 
                divisors.extend((i,n//i)) 
        i = i + 1
    return divisors
 
def countTotalBits(num):
     
     # convert number into it's binary and 
     # remove first two characters 0b.
     binary = bin(num)[2:]
     return(len(binary))
def isPrime(n) : 
  
    # Corner cases 
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
  
    # This is checked so that we can skip  
    # middle five numbers in below loop 
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
  
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
  
    return True
""" def dfs(node,val):
    global tree,visited
    visited[node]=1
    ans[node]=val
    val^=1
    for i in tree[node]:
        if visited[i]==-1:
            dfs(i,val) """

for _ in range(vary(1)):
    n=vary(1)
    s=input()
    count=0
    if n==1 and s[0]=='a':
        print(0)
        continue
    elif n==1:
        print(1)    
        continue

    start=97
    fs=s[:n//2]
    ls=s[n//2:]
    # print(fs,fs.count(chr(97)))
    while 1:
        if len(fs)==0 or len(ls)==0:
            break
        if fs.count(chr(start))>ls.count(chr(start)):
            count+=n//2-fs.count(chr(start))
            s=ls
        elif fs.count(chr(start))<ls.count(chr(start)):
            count+=n//2-ls.count(chr(start))
            s=fs
        else:
            if fs.count(chr(start+1))>ls.count(chr(start+1)):
                count+=n//2-ls.count(chr(start))
                s=fs
            else:
                count+=n//2-fs.count(chr(start))

                s=ls   
        start+=1
        n=n//2
        if n==1:
            if s.count(chr(start))==1:
                break
            else:
                count+=1
                break
        fs=s[:n//2]
        ls=s[n//2:]
    print(count)

        



