from sys import setrecursionlimit
from collections import deque
Z = 'abcdefghijklmnopqrstuvwxyz'

def count(S, c):
    if len(S) == 1:
        if S[0] == Z[c]:
            return 0
        else:
            return 1
    else:
        n = len(S)
        n2 = n // 2
        count0, count1 = 0, 0
        for i in range(n2):
            if S[i] == Z[c]:
                count0 += 1
            if S[i + n // 2] == Z[c]:
                count1 += 1
        ans1 = (n2 - count0) + count(S[n2:], c+1)
        ans2 = (n2 - count1) + count(S[:n2], c+1)
        # print(n, n // 2, S, S[n2:], S[:n2], Z[c])
        # print(" ", ans1, count0)
        # print(" ", ans2, count1)
        return min(ans1, ans2)

def solve():
    # a-string is (aaaa)[b-string] or [b-string](aaaa)
    # b-string is (bbbb)[c-string] or [c-string](bbbb)
    # 前半と後半で多い方を残す
    n = int(input())
    S = input()
    # n = 8
    # S = 'bbdcaaaa'
    print(count(S, 0))


if __name__ == '__main__':
    t = int(input())
    # t = 1
    while t > 0:
        t -= 1
        solve()