def main():
    from string import ascii_lowercase
    dic = {i: a for i, a in enumerate(ascii_lowercase)}
    T = int(input())

    def dfs(N, S, i=0):
        if N == 1:
            return 1 if dic[i] != S[0] else 0
        ret1, ret2 = 0, 0
        ret1 = sum(dic[i] != s for s in S[N//2:])
        ret2 = sum(dic[i] != s for s in S[:N//2])
        ret = min(dfs(N//2, S[:N//2], i+1)+ret1,
                  dfs(N//2, S[N//2:], i+1)+ret2)
        return ret

    for _ in range(T):
        N = int(input())
        S = [s for s in input()]
        print(dfs(N, S))


if __name__ == '__main__':
    main()
