import sys
inputlist=sys.stdin.readlines()
number_of_testcases=int(inputlist[0].strip())
def make_character(character,string,start_index,end_index):
    swaps=0
    for i in range(start_index,end_index+1):
        if(string[i]!=character):
            swaps+=1
    return swaps
def make_good(character,string,start_index,end_index):
    if(start_index==end_index):
        return make_character(character,string,start_index,end_index)
    else:
        mid_index=(start_index+end_index)//2
        result1=make_good(chr(ord(character)+1),string,start_index,mid_index)+make_character(character,string,mid_index+1,end_index)
        result2=make_good(chr(ord(character)+1),string,mid_index+1,end_index)+make_character(character,string,start_index,mid_index)
        return min(result1,result2)
for i in range(number_of_testcases):
    n=int(inputlist[2*i+1].strip())
    string=inputlist[2*i+2].strip()
    ans=make_good('a',string,0,n-1)
    print(ans)
    