import sys
import math


def readStr():
    return sys.stdin.readline().rstrip()


def readInts():
    return list(map(int, readStr().split(' ')))


def readLatins():
    return [ord(c)-97 for c in readStr()]


def main(c, n, s):
    if n == 1:
        if s[0] == c:
            return 0
        else:
            return 1

    n1 = n // 2

    c1 = 0
    c2 = 0
    for i in range(n1):
        if s[i] == c:
            c1 += 1
        if s[-i-1] == c:
            c2 += 1

    k1 = n1 - c1 + main(c+1, n1, s[n1:])
    k2 = n1 - c2 + main(c+1, n1, s[:n1])

    return k1 if k1 < k2 else k2


if __name__ == '__main__':
    (t,) = readInts()

    for _ in range(t):
        (n,) = readInts()
        s = readLatins()

        k = main(0, n, s)
        print(k)
