def goodString(s, len, charCode):
    h, char = len // 2, chr(charCode)
    if len == 1:
        if s == char:
            return 0
        else:
            return 1
    s1, s2 = s[:h], s[h:]
    a1 = h - s1.count(char) + goodString(s2, h, charCode + 1)
    a2 = h - s2.count(char) + goodString(s1, h, charCode + 1)

    return min(a1, a2)


T = int(input())
for _ in range(T):
    N = int(input())
    A = input()
    ans = goodString(A, N, 97)
    print(ans)
