def count_changes(s, c):
    return sum([1 for x in s if x!=c])

def next_alpha(c):
        assert len(c) == 1
        return chr(ord(c) + 1)

def solve(s, c):
    n = len(s)
    if n == 1:
            return 1 if s!=c else 0
    return min(
            solve(s[n//2:], next_alpha(c)) + count_changes(s[:n//2], c),
            count_changes(s[n//2:], c) + solve(s[:n//2], next_alpha(c))
            )
    
if __name__ == "__main__":
    t = int(input())
    while t:
        n = int(input())
        s = input()
        print(solve(s, "a"))
        t-=1