def dp(first ,last , c , x ):
    if first+1 == last and x[first]!= c :
        return 1
    if first+1 == last and x[first] ==c:
        return 0
    mid = (first+last)//2
    out1 = count(first,mid,c,x)+ dp(mid,last,chr(ord(c)+1),x)
    out2 = count(mid,last,c,x)+ dp(first,mid,chr(ord(c)+1),x)
    return min(out1,out2)


def count(first ,last ,c,x):
    count =0
    for i in range (first,last):
        if x[i] !=c:
            count+=1
    return count

for _ in range(int(input())):
    y = int(input())
    x = input()
    print(dp(0,y,'a',x))




