def main():
    def rec(s, d, n):
        tgt = chr(97+d)
        if n == 0:
            return 0 if s == tgt else 1

        cnt = 0
        for c in s[:n]:
            cnt += (c != tgt)
        ret = cnt + rec(s[n:], d+1, n//2)

        cnt = 0
        for c in s[n:]:
            cnt += (c != tgt)
        ret = min(ret, cnt + rec(s[:n], d+1, n//2))

        return ret

    for __ in [0]*int(input()):
        N = int(input())
        S = input()

        print(rec(S, 0, N//2))


if __name__ == '__main__':
    main()
