def func(s,c):
    if(len(s)==1):
        if(s[0]==c):
            return 0;
        else:
            return 1;
    t=s[0:len(s)//2]
    m=s[len(s)//2:]
    return min(len(t)-t.count(c)+func(m,chr(ord(c)+1)),len(t)-m.count(c)+func(t,chr(ord(c)+1)));

a=int(input())
for i in range(a):
    r=int(input())
    s=input()
    x=func(s,'a')
    print(x)
