test = int(input())

letters = "abcdefghijklmnopqrstuvwxyz"


def a_good(s, i):
    if len(s) == 1:
        if s == letters[i]:
            return 0
        else:
            return 1
    else:
        moves = 0

        # If second half has more of the required letter, swap the halves
        if s[:len(s) // 2].count(letters[i]) < s[len(s) // 2:].count(letters[i]):
            s = s[len(s) // 2:] + s[:len(s) // 2]

        # Find the number of moves required to make the first half of the string "good"
        # All letters should be the required letter
        moves += (len(s) // 2) - s[:len(s) // 2].count(letters[i])

        # Do recursion to see if second half is a good string
        return moves + a_good(s[len(s) // 2:], i + 1)


for t in range(test):
    n = int(input())
    s = input()

    print(a_good(s, 0))
