# def make_good(letter, length):
#     if(length==1):
#         return letter
#     temp = make_good(chr(ord(letter)+1),int(length/2))
#     ans = []
#     for i in range(len(temp)):
#         ans.append(temp[i] + letter*int(length/2))
#         ans.append(letter*int(length/2) + temp[i])
#     return ans

# def diff(str1,str2):
#     ans = 0
#     for i in range(len(str1)):
#         if str1[i]!=str2[i]:
#             ans+=1
#     return ans

def count(s,c):
    ans = 0
    for i in range(len(s)):
        if s[i]==c:
            ans+=1
    return ans

def calcMin(s,l,r,c):
    if(r-l == 1):
        if s[l]!=c:
            return 1
        else:
            return 0
    mid = int((l+r)/2)
    ansLeft = (r-l)/2 - count(s[l:mid],c) + calcMin(s,mid,r,chr(ord(c)+1))
    ansRight = calcMin(s,l,mid,chr(ord(c)+1)) + (r-l)/2 - count(s[mid:r],c)
    return int(min(ansLeft,ansRight))


t = int(input())
n_list = [0 for i in range(t)]
str_list = [[""] for i in range(t)]

for i in range(t):
    n_list[i] = int(input())
    str_list[i] = input()

output_list = [0 for i in range(t)]
for i in range(t):
    # seq_list = make_good("a",n_list[i])
    # ans = n_list[i]
    # for j in range(len(seq_list)):
    #     ans = min(ans,diff(str_list[i],seq_list[j]))
    # output_list[i] = ans
    output_list[i] = calcMin(str_list[i],0,n_list[i],"a")

for i in range(t):
    print(output_list[i])    



