def solve(s,ans,c):
    if len(s)==1:
        if s[0]!=c:
            return ans+1
        return ans
    cnt1 = 0
    cnt2 = 0
    for i in range(0,len(s)//2):
        if s[i]!=c:
            cnt1 += 1
    for i in range(len(s)//2,len(s)):
        if s[i]!=c:
            cnt2 += 1
    x = solve(s[:len(s)//2],ans+cnt2,chr(ord(c)+1))
    y = solve(s[len(s)//2:],ans+cnt1,chr(ord(c)+1))
    return min(x,y)

t = int(input())
while t>0:
    n = int(input())
    s = input()
    print(solve(s,0,'a'))
    t -= 1