def solve(s,ch):
    if len(s)==1:
        if ch==s:
            return 0
        else:
            return 1
    first=s[:len(s)//2]
    second=s[len(s)//2:]
    cnt1=len(first)-first.count(ch)+solve(second,chr(ord(ch)+1))
    cnt2=len(second)-second.count(ch)+solve(first,chr(ord(ch)+1))
    return min(cnt1,cnt2)

def main():
    t=int(input())
    for _ in range(t):
        n=int(input())
        s=input()
        print(solve(s,'a'))
        
main()