def calc(l, r, s, letter):
    if r - l == 1:
        return 0 if s[l] == letter else 1
    mid = (l + r) // 2
    cnt_l = (r - l) // 2 - s[l : mid].count(letter)
    cnt_r = (r - l) // 2 - s[mid : r].count(letter)
    #print (l, r, cnt_l, cnt_r)
    return min(cnt_l + calc(mid, r, s, chr(ord(letter) + 1)),
                cnt_r + calc(l, mid, s, chr(ord(letter) + 1)))
    

t = int(input())
for _ in range(t):
    n = int(input())
    s = input()
    print(calc(0, n, s, 'a'))
    

        
    

    
    