for _ in range(int(input())):
       n = int(input())
       s = input()


       def doit(l, r, c):
              if l == r:
                     return int(c != s[l])
              mid = (l+r)>>1
              cntl = doit(l, mid, chr(ord(c)+1))+mid-l+1-s[mid+1:r+1].count(c)
              cntr = doit(mid+1, r, chr(ord(c)+1))+r-mid-s[l:mid+1].count(c)
              return min(cntl, cntr)

       print(doit(0, n-1, 'a'))
