from math import log2, ceil, floor
from collections import defaultdict, OrderedDict, Counter, deque
from heapq import heappush, heappop, heapify

def inp():
    return input()
def list_inp():
    return list(map(int,input().split()))
def map_inp():
    return map(int,input().split())
def int_inp():
    return int(input())
def float_int():
    return float(input())
    
def isprime(n):
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
    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 check(s,n,k):
    if n<=1:
        if s[0]==chr(k):
            return 0
        else:
            return 1

    elif k==122:
        return n-s.count(chr(k))
    else:
        first = s[:n//2].count(chr(k))
        second =s[n//2:].count(chr(k))
    
        # return (min(first,second) + min(check(s[n//2:],n//2,k+1),check(s[:n//2],n//2,k+1)))
        if first>second:
            return (n//2-first)+check(s[n//2:],n//2,k+1)
        elif second>first:
            return (n//2-second)+check(s[:n//2],n//2,k+1)
        else:
            if k+1<=122:
                first_next = s[:n//2].count(chr(k+1))
                second_next = s[n//2:].count(chr(k+1))
                if first_next>second_next:
                    return (n//2-first)+check(s[:n//2],n//2,k+1)
                else:
                    return (n//2-second)+check(s[n//2:],n//2,k+1)
            

for _ in range(int_inp()):
    n = int_inp()
    s = list(inp())
    if n==1:
        if s[0]=='a':
            print(0)
        else:
            print(1)
    else:
        ans = check(s,n,97)
        print(ans)        
