from collections import defaultdict as dd
import sys
input=sys.stdin.readline
t=int(input())
def solve(curr,i,j,s):
    #print(curr)
    #print(i,j)
    if(i==j):
        return int(s[i]!=curr)
    if(i>j):
        return 0
    mid=(i+j)//2
    
    x=0
    for ii in range(i,mid+1):
        if(s[ii]!=curr):
            x+=1
    y=0
    for ii in range(mid+1,j+1):
        if(s[ii]!=curr):
            y+=1
    x=x+solve(chr(ord(curr)+1),mid+1,j,s)
    y=y+solve(chr(ord(curr)+1),i,mid,s)
    return min(x,y)
while t:
    n=int(input())
    s=input().split()[0]
    print(solve('a',0,n-1,s))
    t-=1
    