import math

def go(s,n,x):
    if(n==1):
        if s[0]==x:
            return 0
        else:
            return 1

    val1 = 0 
    for c in s[:int(n/2)]:
        if c!=x:
            val1+=1
    val2 = 0 
    for c in s[int(n/2):]:
        if c!=x:
            val2+=1
    if val2<val1:
        return val2+go(s[:int(n/2)],n/2,chr(ord(x)+1))
    else:
        return val1+go(s[int(n/2):],n/2,chr(ord(x)+1))

    
    



if __name__ == "__main__":
    t = int(input().strip())
    for _ in range(t):
        n= int(input().strip())
        s = input().strip()
        print(go(s,n,'a'))