for _ in range(int(input())):
  n=int(input())
  s=input()
  i=0; a=0; b=n;x,y=0,0; c=0
  while True and n!=1:
    #print(x,y,a,b)
    #print(s[a+b//2:a+b])
    x=s[a:a+b//2].count(chr(97+i))
    y=s[a+b//2:a+b].count(str(chr(97+i)))
    #print(x,y)
    if x>=y: c+=max(0,b//2-x,0); a+=b//2
    else: c+=max(b//2-y,0)
    b=b//2    
    i+=1
    if b<=1: break
  if n==1:
    print(0 if s=='a' else 1)
  else:
    print(c if s[a]==str(chr(97+i)) else c+1)
    