for _ in range(int(input())):
     n=int(input())
     s=input()
     k=0
     c=97
     mine=""
     while(n>0):
          n=n//2
          for i in range(n):
               mine=mine+(chr(c+k))
          k=k+1

     mine=mine+chr(c+k-1)     
     count=0
     for i in range(n):
          if(s[i]!=mine[i]):
               count=count+1
               
     print(count)

          
          
          