def c(li,l,h,good):
    if(h-l==1):
        if(li[l]==good):
            return 0
        return 1
    m=l+(h-l)//2
    return min((h-l)//2-li[l:m].count(good) +c(li,m,h,chr(ord(good)+1)),(h-l)//2-li[m:h].count(good) +c(li,l,m,chr(ord(good)+1)))
def main():
	for _ in range(int(input())):
		n=int(input())
		a=list(input())
		print(c(a,0,n,'a'))
main()