from sys import stdin,stdout,setrecursionlimit

def getCost(s,l,h,ch):
    cnt = 0
    for i in range(l,h+1):
        if s[i] != ch:
            cnt += 1
    return cnt


def getMin(s,l,h,ch):
    if l == h:
        if s[l] == ch:
            return 0
        return 1
    mid = (l+h)//2
    
    return min(getCost(s,l,mid,ch)+getMin(s,mid+1,h,chr(ord(ch)+1)), getCost(s,mid+1,h,ch)+getMin(s,l,mid,chr(ord(ch)+1)))

t = int(stdin.readline())
for _ in range(t):
    n = int(stdin.readline())
    # a = list(map(int,stdin.readline().split()))
    s = stdin.readline()
    print(getMin(s,0,n-1,'a'))