
def find(list1,start,endi,num):
    alpha = chr(ord("a")+num)

    if start==endi:
        if list1[start]==alpha:
            return 0
        else:
            return 1
    count1=0
    count2=0
    count3=0
    count4=0
    mid = (start+endi)//2
    for i in range(mid+1):
        if list1[i]!=alpha:
            count1+=1

    for i in range(mid+1,endi+1):
        if list1[i]!=alpha:
            count2+=1

    return min(count1+find(list1,mid+1,endi,num+1),count2+find(list1,start,mid,num+1))




t = int(input())
while t!=0:

    n = int(input())
    s = list(input())
    print(find(s,0,n-1,0))

    t-=1