def min_cost(s,start,size,c):
    if(size==1):
        if(s[start]==c):
            return 0
        else:
            return 1

    new_size = size//2

    a1 = new_size-s[start:start+new_size].count(c) + min_cost(s,start+new_size,new_size,chr(ord(c)+1))
    b1 = min_cost(s,start,new_size,chr(ord(c)+1)) + new_size - s[start+new_size:start+2*new_size].count(c)
    
    # print(a1,b1)
    return min(a1,b1)


t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    ans = min_cost(s,0,n,'a')

    # print("ANS",ans)
    print(ans)

