def recur(s,n,ch):
    if n==1:
        return 0 if s==ch else 1
    firsthalf = 0
    secondhalf = 0
    for c in s[:n//2]:
        if c==ch:
            firsthalf+=1
    for c in s[n//2:]:
        if c==ch:
            secondhalf+=1
    return min((n//2-secondhalf) + recur(s[:n//2],n//2,chr(ord(ch)+1)),(n//2-firsthalf) + recur(s[n//2:],n//2,chr(ord(ch)+1)))
    
for _ in range(int(input())):
    n = int(input())
    s = input()
    print(recur(s,n,'a'))