for _ in range(int(input())):
    s = 0
    am = int(input())
    arr = list(input())
    n = 0
    tot = 0
    def f(s):
        global tot
        global n
        if (len(s) == 1):
            tot += (s[0] != chr(97+n))
            return 0
        fir = 0
        sec = 0
        for i in range(len(s)//2):
            fir += int( s[i] != chr(97+n))
        for i in range(len(s)//2,len(s)):
            sec += int( s[i] != chr(97+n))
        n+=1
        if fir > sec:
            tot+=sec
            f(s[:len(s) // 2])
        else:
            tot+=fir
            f(s[len(s) // 2:])
    f(arr)
    print(tot)
