def recur(s,p):
    if len(s) == 1 :
        c = chr(96+p)
        if s == c :
            return 0 
        return 1 
    n = len(s)//2
    left = s[:n]
    right = s[n:]
    c = chr(96+p)
    # nxt = chr(96+p+1)
    d1 = {}
    d2 ={}
    for i in range(n):
        d1[left[i]] = d1.get(left[i],0) + 1 
        d2[right[i]] = d2.get(right[i],0) + 1 
    val1 = d1.get(c,0)
    val2 = d2.get(c,0)
    left_ans = n - val1 + recur(right,p+1)
    right_ans = n - val2 + recur(left,p+1)
    return min(left_ans,right_ans)
for _ in range(int(input())):
    n = int(input())
    s = input()
    val = recur(s,1)
    print(val)