"""
Author: Q.E.D
Time: 2020-07-17 10:11:52
"""
def count(s, c):
    c2 = chr(ord(c) + 1)
    if len(s) == 1:
        return 1 - int(s[0] == c)
    else:
        n = len(s)
        h = n // 2
        x1 = sum(1 for a in s[:h] if a != c)
        x2 = sum(1 for a in s[h:] if a != c)
        y1 = count(s[h:], c2)
        y2 = count(s[:h], c2)
        return min(x1 + y1, x2 + y2)

T = int(input())
for _ in range(T):
    n = int(input())
    s = input()
    ans = count(s, 'a')
    print(ans)