def chek(s,n,ch):
    if n == 1 and s == ch:
        return 0
    if n == 1 and s != ch:
        return 1
    if s[0:n//2] == ch * (n // 2) and not chek(s[n//2:], n//2, chr(ord(ch) + 1)) or ((not chek(s[0:n//2],n//2, chr(ord(ch) + 1)) and s[n//2:] == (n//2) * ch )):
        return 0
    m = min(chek(s[0:n//2], n//2, ch) + chek(s[n//2:], n//2, chr(ord(ch) + 1)), chek(s[0:n//2], n//2, chr(ord(ch) + 1)) + chek(s[n//2:], n//2, ch))
    return m

for i in range(int(input())):
    sm = 0
    n = int(input())
    s = input()
    print(chek(s,n,'a'))
