def get_cost(ls, start, end, letter):
    
    if start < end:
        mid = (end-start)//2 + start
        
        cost_1 = 0
        for item in ls[start:mid+1]:
            if item != letter:
                cost_1 += 1
        cost_2 = 0
        for item in ls[mid+1:end+1]:
            if item != letter:
                cost_2 += 1
        
        cost_1 += get_cost(ls, mid+1, end, chr(ord(letter)+1))
        cost_2 += get_cost(ls, start, mid, chr(ord(letter)+1))

        return min(cost_1, cost_2)
    
    elif start == end:
        if ls[start] == letter:
            return 0
        else:
            return 1
    
    else:
        return 0
        
tests = int(input())
for t in range(tests):
    n = int(input())
    ls = input()
    ls_len = len(ls)
    
    print(get_cost(ls, 0, len(ls)-1, 'a'))