from sys import stdin, gettrace

if gettrace():
    inputi = input
else:
    def input():
        return next(stdin)[:-1]


    def inputi():
        return stdin.buffer.readline()


def makegoodl(ss,c):
    res = makegood(ss[len(ss)//2:], chr(ord(c) + 1))
    for s in ss[:len(ss)//2]:
        if s != c:
            res += 1
    return res


def makegoodr(ss, c):
    res = makegood(ss[:len(ss)//2], chr(ord(c) + 1))
    for s in ss[len(ss)//2:]:
        if s != c:
            res += 1
    return res


def makegood(ss, c):
    if len(ss) == 1:
        return 0 if ss == c else 1
    return min(makegoodl(ss, c), makegoodr(ss, c))

def solve():
    _ = input()
    print(makegood(input(), 'a'))


def main():
    t = int(inputi())
    for _ in range(t):
        solve()


if __name__ == "__main__":
    main()