
def bs(l,r,ch):
    if l == r:
        if s[l] == ch: return 0
        else: return 1
    mid = (l+r) // 2
    return min((mid - l+1)-s[l:mid+1].count(ch) + bs(mid+1,r,chr(ord(ch)+1)),
               
                (r-mid)-s[mid+1:r+1].count(ch) + bs(l,mid,chr(ord(ch)+1)))   


for _ in range(int(input())):
    n = int(input())

    s = input()

    print(bs(0,n-1,"a"))
