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

    if len(list1)==1:
        if list1[0]==alpha:
            return 0
        else:
            return 1
    list12 = list1[:len(list1)//2]
    list13 = list1[len(list1)//2:]
    count1=0
    count2=0
    for i in range(len(list12)):
        if list12[i]!=alpha:
            count1+=1
    for i in range(len(list13)):
        if list13[i]!=alpha:
            count2+=1
    return min(count1+find(list13,num+1),count2+find(list12,num+1))




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

    n = int(input())
    s = (input())
    print(find(s,0))

    t-=1