import sys, math
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

import collections as col
import math

def solve():
    N = getInt()
    A = listStr()
    #min(moves to make left half all a + moves to make right half b-good, moves to make right half all a + moves to make right left b-good)
    def solve2(S,targ):
        LL = len(S)
        if LL == 1:
            return 1*(S[0] != targ)
        count1, count2 = S[:LL//2].count(targ), S[LL//2:].count(targ)
        new_targ = chr(ord(targ)+1)
        return min(LL//2-count1+solve2(S[LL//2:],new_targ),LL//2-count2+solve2(S[:LL//2],new_targ))
    return solve2(A,'a')
    
        
for t in range(getInt()):
    print(solve())
