def main():
    for case in range(int(input())):
        n = int(input())
        print(res(input(), 'a'))
    
def res(s, a):
    n = len(s)
    if n==1:
        return int(s[0]!=a)
    if n!=1:
        res1 = res(s[n//2:] , chr(ord(a)+1))- s[:n//2].count(a)
        res2 = res(s[:n//2], chr(ord(a)+1)) - s[n//2:].count(a)
        m=min(res1,res2)
        return [n//2+m,int(s[0]!=a)][n==1] 

main()