import math

def calc(s, c, count):


    if len(s) == 1:
        if s[0] != c:

            return  1+count
        else:
            return count
    i = len(s) // 2
    a = s[:i]
    b = s[i:]
    ac = a.count(c)
    bc = b.count(c)

    c = chr(ord(c) + 1)

 
    count1 = len(a) - ac + calc(b,c,count)

    count2 = len(a) - bc + calc(a,c,count)


        
    # print(count, a,b)
    return min(count1, count2)
for _ in range(int(input())):
    n = int(input())
    s = input()
    chars = int(math.log(n, 2)) + 1
    side = False
    i = n
    c = 'a'

    count = calc(s, c, 0)

    print(count)