import string

alphabet = list(string.ascii_lowercase)

def func(input_string,alp_num,count):
    if len(input_string) == 2 and alp_num == 0:
        for i in input_string:
            if i != alphabet[alp_num]:
                count +=1
        return count
    if len(input_string) == 1:
        if input_string != alphabet[alp_num]:
            count += 1
            return count
        else:
            return count
        
    letter = alphabet[alp_num]
    pair1 = input_string[0:int(len(input_string)/2)]
    pair2 = input_string[int(len(input_string)/2):len(input_string)]
    if pair1.count(letter) >= pair2.count(letter):
        selected_pair , unselected_pair = list(pair1) , pair2
    else:
        selected_pair , unselected_pair = list(pair2) , pair1
    for i in range(len(selected_pair)):
        if selected_pair[i] != letter:
            selected_pair[i] = letter
            count += 1
    alp_num +=1
    
    return func(unselected_pair,alp_num,count)
    



test_case = int(input())
output = []
for i in range(test_case): 
    int(input())
    input_string = input()
    output.append(func(input_string,0,0))

for i in output:
    print(i)


