def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) ]))
def invr():
    return(map(int,input().split()))

def solve(begin,end,char,count,s):
    mid_point = (begin+end)//2
    if(end == begin + 1):
        if(s[begin] == char):
            return count
        else:
            return count + 1
    counter1 = 0
    counter2 = 0

    for j in range(begin, mid_point):
        if(s[j] != char):
            counter1 += 1

    for j in range(mid_point, end):
        if(s[j] != char):
            counter2 += 1
    #print(char)
    #print(begin,end, counter1, counter2, count)
    return(min(solve(begin,mid_point, chr(ord(char) + 1), count + counter2, s), solve(mid_point,end, chr(ord(char) + 1), count + counter1, s)))

n = inp()

for i in range(n):
    m = inp()

    s = insr()

    ans = solve(0,m,'a',0,s)
    print(ans)
