def main():
    n = int(input())
    for i in range(n):
        solve()

def solve():
    n = int(input())
    arr = list(input())

    pos = 0
    front = []
    back = []
    current_letter = 'a'

    current = n // 2
    while current >= 1:
        if pos == 0:
            for i in range(current):
                front.append(current_letter)
            pos = 1
        else:
            for i in range(current):
                back.insert(0, current_letter)
            pos = 0
        current = current // 2
        current_letter = chr(ord(current_letter) + 1)

    if pos == 0:
        front.append(current_letter)
    else:
        back.insert(0, current_letter)
    
    one = "".join(front) + "".join(back)
    two = one[::-1]

    scores = [0, 0]

    for index, val in enumerate(arr):
        if val != one[index]:
            scores[0] += 1
        if val != two[index]:
            scores[1] += 1
    
    print(min(scores))

main()