# Global variable  for efficient access
s = ''
def count_replacement(lo: int, hi: int, b: str):
    count = 0
    for i in range(lo, hi+1):
        char = s[i]
        if char != b:
            count+=1
    return count

def good_moves(lo : int, hi: int, c : str):
    mid = (lo+hi)//2
    if lo == hi:
        if s[lo] == c:
            return 0
        else:
            return 1
    first_half = count_replacement(lo, mid, c) + good_moves(mid+1, hi, chr(ord(c)+1))
    second_half = count_replacement(mid+1, hi,c) + good_moves(lo, mid, chr(ord(c)+1))
    return min(first_half, second_half)
    
for _ in range(int(input())):
    n = int(input())
    s = input()
    print(good_moves(0,n-1,'a'))
